Skip to content

Just a simple project trying to clear up JPAs merge() and persist()

Notifications You must be signed in to change notification settings

shinlang/jpatest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jpatest

Just a simple project trying to clear up JPAs merge() and persist(). If you want to deploy it, you probably have to change the persistence.xml, as I'm using the sample JDBC resource (Derby Pool) that comes with glassfish.

From the examples in the MyModel class I came up with these simple rules:

  • Use container managed transactions, annotate @TransactionAttribute to your classes and methods if necessary (REQUIRED is default)
  • If you want to insert an entity into the database -> use persist()
  • If you want to save an entity to the database, but you're not sure if it already exists -> use merge()
  • If you want to update an existing entity -> get an attached object and use neither merge() nor persit()

About

Just a simple project trying to clear up JPAs merge() and persist()

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages