[appengine-java] Re: Spring 2.5 Transactions - anyone got this working?
Hi Objectuser, Thanks for the suggestions. Pointcut is correct (I think so - keep second guessing myself though trying to implement this). I changed the domain to something generic when posting the example. Can you please confirm the following is correct, ie that you inject the proxy into the transaction manager. bean id=txManager class=org.springframework.orm.jdo.JdoTransactionManager property name=persistenceManagerFactory ref=persistenceManagerFactoryProxy / /bean The Spring 2.5 reference documentation in section 12.3.4 (http:// static.springsource.org/spring/docs/2.5.x/reference/orm.html#orm-jdo) has only the persistence manager factory. But it looks to me like it not in the context of using the proxy for transaction management. Some operations will work if I only inject the persistenceManagerFactory but then some will not (however all fail for testcases) I cannot get a testcase to work using spring managed transactions. Interestingly if I inject just the persistenceManagerFactory into the txManager bean some operations work but no testcase will work. Setting up testcases for the datastore is a real pain and I have followed the directions as per the google doco. Will try taking out the close methods and see if that makes a difference. Will keep bashing my head against this appengine wall. Cheers, Carl. On Mar 31, 2:10 pm, objectuser kevin.k.le...@gmail.com wrote: Check your pointcut ... is com.myapp.dao... correct? If that's correct, then I don't see anything amiss; it looks really good. Are you even able to setup a test where it works? Or are you doing it from a test? Oh, and check the use of pm.close(). That should be taken care of bySpringI think. I don't do it in my app anyway. If those don't work, then I'll looks again. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Spring 2.5 Transactions - anyone got this working?
Hi objectuser, Thanks for the links - very helpful. I have had a look and studied them. I am trying to get your example to work but am getting the error. org.springframework.transaction.CannotCreateTransactionException: Could not open JDO PersistenceManager for transaction; nested exception is java.lang.IllegalStateException: No JDO PersistenceManager bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.jdo.JdoTransactionManager.doBegin(JdoTransactionManager.java: 359) As far as I can see I have set up everything as should be but am missing something obvious because it just will not work. It might be something to do with the aop config but I cannot be sure. I have read the Spring documentation and your example which are very similar. Below is my revised spring xml and I have included example dao code as well. If anyone can see what I am doing wrong please correct me. Thanks. SPRING XML - bean id=projectDao class=com.myapp.dao.ProjectDaoJdoImpl property name=pmf ref=persistenceManagerFactoryProxy / /bean bean id=persistenceManagerFactory class=org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean property name=persistenceManagerFactoryName value=transactions- optional / /bean bean id=persistenceManagerFactoryProxy class=org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy property name=targetPersistenceManagerFactory ref=persistenceManagerFactory / property name=allowCreate value=false / /bean bean id=txManager class=org.springframework.orm.jdo.JdoTransactionManager property name=persistenceManagerFactory ref=persistenceManagerFactoryProxy / /bean tx:advice id=txAdvice transaction-manager=txManager tx:attributes tx:method name=clearAndCreate propagation=REQUIRED rollback-for=Throwable / tx:method name=create propagation=REQUIRED rollback- for=Throwable/ tx:method name=update propagation=REQUIRED rollback- for=Throwable / tx:method name=delete propagation=REQUIRED rollback- for=Throwable / tx:method name=* read-only=true/ /tx:attributes /tx:advice aop:config aop:pointcut id=daoMethods expression=execution(* com.myapp.dao.*.*(..))/ aop:advisor advice-ref=txAdvice pointcut-ref=daoMethods/ /aop:config DAO - public class ProjectDaoJdoImpl implements ProjectDao { private PersistenceManagerFactory pmf; public void setPmf(final PersistenceManagerFactory pmf) { this.pmf = pmf; } private PersistenceManager getPersistenceManager() { return pmf.getPersistenceManager(); } public Project read(Long id) { PersistenceManager pm = getPersistenceManager(); try { Project project = pm.getObjectById(Project.class,id); return project; } finally { pm.close(); } } } -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Spring 2.5 Transactions - anyone got this working?
Sorry as well at the moment I am only trying to get this to work on my local version of appengine (the SDK). I will look at the workaround posted at http://code.google.com/p/googleappengine/issues/detail?id=1381 once I have it all working. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Spring 2.5 Transactions - anyone got this working?
Hi All, I have been trying for a while now to get Spring managed transactions working on GAE without success. I have searched these forums and the web and find a few examples, all slightly different, and none of which work for me. I am getting the error class javax.jdo.JDOUserException: Transaction is still active. You should always close your transactions correctly using commit() or rollback(). This makes total sense to me in that Spring is not closing the transaction but I don't understand why I am getting it with the following configuration any ideas/ examples greatly appreciated. When I don't use transactions it all works great. But I really need the transactions and would love it to be controlled via Spring. I am using the latest version of GAE 1.3.2. bean id=persistenceManagerFactory class=org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean property name=persistenceManagerFactoryName value=transactions- optional / /bean bean id=txManager class=org.springframework.orm.jdo.JdoTransactionManager property name=persistenceManagerFactory ref=persistenceManagerFactory / property name=jdoDialect ref=dataNucleusJdoDialect/ /bean bean id=dataNucleusJdoDialect class=org.datanucleus.springframework.DataNucleusJdoDialect/ tx:advice id=txAdvice transaction-manager=txManager tx:attributes tx:method name=clearAndCreate propagation=REQUIRED rollback- for=Throwable / tx:method name=create propagation=REQUIRED rollback- for=Throwable/ tx:method name=update propagation=REQUIRED rollback- for=Throwable / tx:method name=delete propagation=REQUIRED rollback- for=Throwable / tx:method name=* propagation=NOT_SUPPORTED read-only=true/ /tx:attributes /tx:advice aop:config aop:advisor pointcut=execution(* com.mydomain.myapp.dao.*.*(..)) advice-ref=txAdvice/ /aop:config -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Cannot have a java.lang.Long primary key and be a child object
Hi All, I have two classes, a Parent and a Child. (See below for code) The Parent class contains a reference to a Child instance. However when I try and save a Parent instance I get the following error: Cannot have a java.lang.Long primary key and be a child object. The error is clear enough and upon searching around I have found the solution is to convert the primary key of my Child class to Key. However this just does not sit well with me that I have to modify my domain classes with proprietary google classes to suit the datastore. Is there no other way to do this without resorting to custom APIs at the domain level? Or is this a limitation of JDO and I need to do a bit more research? Cheers, Carl. @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Parent { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private String name; @Persistent private Child child; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Child getChild() { return child; } public void setChild(Child child) { this.child = child; } } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Child { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.