[jboss-user] [JBoss Seam] - extended persistence context with JavaBeans ?

sirandreus do-not-reply at jboss.com
Mon Aug 13 11:02:44 EDT 2007


Hi,

How can I enable an extended persistence context using JavaBeans ? (without EJB). 

I could not manage not get it work. Please read on in order to understand the problem.

Im using Seam with the following configuration:
- Seam 2.0 Beta1
- JBoss AS 4.2.1
- JavaBeans (without EJB)
- created Project using seam-gen as a war (not ear)

In the Seam book "Simplicity and Power beyond JEE" the author says that the persistence context of all Seam POJOs is extended.

In order to make sure, that this is true, I´ve ported the Clickable Lists example (from the official Tutorial := http://docs.jboss.org/seam/latest-2.0/reference/en/html/tutorial.html#messages) into the JavaBeans Model. The only differences are:

1) no @Statefull Annotation at the MessageManagerBean class
2) added @Transactional at MessageManagerBean class (as a class level annotation, so that every method is made trasactional)
3) instad of @PersistenceContext, I use @In

The problem is, that the PersistenceContext is not extended as expected. For example, after calling the "select" method, a database update does "not" happen. 


  | 	public void select() {
  | 		message.setRead(true);
  | 	}
  | 

However if I replace the implementation with the following code, everything is fine (update happens):


  | 	@Transactional
  | 	public void select() {
  | 		Message mergedMessage = entityManager.merge(message);
  | 		mergedMessage.setRead(true);
  | 
  | 		//message.setRead(true);
  | 	}
  | 

The only logical explanation is that the PersistenceContext is not extended. Because if it was, the original select implementation should synchronize the state of the object with the database (and thus making an update).


thanks for your help,
Andreas

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073599#4073599

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073599




More information about the jboss-user mailing list