Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

added hibernate example #271

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

added hibernate example #271

wants to merge 7 commits into from

Conversation

skelt
Copy link

@skelt skelt commented Jul 6, 2015

Added an example for JPA

@joscha
Copy link
Owner

joscha commented Jul 6, 2015

uh wow, could you please

  • rename the sample into hibernate
  • exclude the target folder
  • make modules a symlink

for a start? Right now, the changeset contains way too much noise to see the actual changes.

Stewart Kelt added 2 commits July 6, 2015 11:50
exclude the target folder
make modules a symlink
@skelt
Copy link
Author

skelt commented Jul 6, 2015

Ok i think thats it (new to github)

@joscha
Copy link
Owner

joscha commented Jul 6, 2015

Much smaller :) Do you think you could also remove all other clutter that is not needed by the JPA example (e.g. views, test base classes, etc.) to make it even smaller?

@skelt
Copy link
Author

skelt commented Jul 6, 2015

I think this is as small as i can make it, unless you can see anything else obvious? :)

@skelt
Copy link
Author

skelt commented Jul 7, 2015

Looking at adding a session factory rather than the developer having to call em.close() - will let you know how i get on.

@skelt
Copy link
Author

skelt commented Jul 7, 2015

Using session factory over entity manager has the same effect, the developer is responsible for closing sessions. I also looked at an example that uses a proxy to create a session for each transaction request, releasing it when commit is called. The code is more maintainable, but it does not support lazy loading. There is also the issue of only one session running on the main thread that could create a bottleneck/concurrency issues. The code can be seen here if interested: https://github.com/skelt/play-authenticate-hibernate/tree/session-factory

So it looks like the latest commit is the preferred option due to it being fully JPA compliant and thread safe. The only issue is you can't really use @transactional with this, it will only works if there are no nested transactions.

@joscha
Copy link
Owner

joscha commented Jul 8, 2015

I think the amount of duplicated code from the main sample is still too high - if we merged this, it would get update hell at some point in time. I wonder if it would be better to extract the samples from the main repository into its own repos, where these can be forked and then adapted (so in the case of hibernate, only the changed and new files would need to be checked in, everything else would come from upstream). What do you think @mkurz ?

tables preventing unnecessary transactions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants