Timestamp in JPQL where clause issue
Hello, I met an OpenJPA Timestamp filed in JPQL where clause issue. I used it as: EntityManagerFactory factory = Persistence.createEntityManagerFactory( test, System.getProperties()); String sql= SELECT callpath FROM Callpath callpath WHERE callpath.starttime :from; Query query = factory.createEntityManager().createQuery(sql); query.setParameter(from, new Timestamp(System.currentTimeMillis()), TemporalType.TIMESTAMP); query.getResultList(); The Exception stack: openjpa-1.2.1-r752877:753278 nonfatal user error org.apache.openjpa.persistence.ArgumentException: Encountered callpath . starttime : from at character 46, but expected: [(, *, +, -, ., /, :, , =, , =, , =, ?, ABS, ALL, AND, ANY, AS, ASC, AVG, BETWEEN, BOTH, BY, CONCAT, COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DELETE, DESC, DISTINCT, EMPTY, ESCAPE, EXISTS, FETCH, FROM, GROUP, HAVING, IN, INNER, IS, JOIN, LEADING, LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL, OBJECT, OF, OR, ORDER, OUTER, SELECT, SET, SIZE, SOME, SQRT, SUBSTRING, SUM, TRAILING, TRIM, UPDATE, UPPER, WHERE, DECIMAL_LITERAL, IDENTIFIER, INTEGER_LITERAL, STRING_LITERAL]. at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501) at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378) at org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947) at org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925) at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791) at org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753) at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556) at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91) at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.init(JPQLExpressionBuilder.java:1727) at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48) at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:625) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492) at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) And I noticed a bug track: http://mail-archives.apache.org/mod_mbox/openjpa-dev/200801.mbox/%3c2013506.1200781234450.javamail.j...@brutus%3e Has it been resolved? Or do I have a workaround? Thanks! Regards, Yu Wang
Re: Timestamp in JPQL where clause issue
And I used OpenJPA 1.2.1. -Yu Wang On Mon, Jul 27, 2009 at 2:20 PM, wang yuwangy...@gmail.com wrote: Hello, I met an OpenJPA Timestamp filed in JPQL where clause issue. I used it as: EntityManagerFactory factory = Persistence.createEntityManagerFactory( test, System.getProperties()); String sql= SELECT callpath FROM Callpath callpath WHERE callpath.starttime :from; Query query = factory.createEntityManager().createQuery(sql); query.setParameter(from, new Timestamp(System.currentTimeMillis()), TemporalType.TIMESTAMP); query.getResultList(); The Exception stack: openjpa-1.2.1-r752877:753278 nonfatal user error org.apache.openjpa.persistence.ArgumentException: Encountered callpath . starttime : from at character 46, but expected: [(, *, +, -, ., /, :, , =, , =, , =, ?, ABS, ALL, AND, ANY, AS, ASC, AVG, BETWEEN, BOTH, BY, CONCAT, COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DELETE, DESC, DISTINCT, EMPTY, ESCAPE, EXISTS, FETCH, FROM, GROUP, HAVING, IN, INNER, IS, JOIN, LEADING, LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX, MEMBER, MIN, MOD, NEW, NOT, NULL, OBJECT, OF, OR, ORDER, OUTER, SELECT, SET, SIZE, SOME, SQRT, SUBSTRING, SUM, TRAILING, TRIM, UPDATE, UPPER, WHERE, DECIMAL_LITERAL, IDENTIFIER, INTEGER_LITERAL, STRING_LITERAL]. at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501) at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378) at org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947) at org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925) at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791) at org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753) at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556) at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91) at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.init(JPQLExpressionBuilder.java:1727) at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48) at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:625) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492) at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) And I noticed a bug track: http://mail-archives.apache.org/mod_mbox/openjpa-dev/200801.mbox/%3c2013506.1200781234450.javamail.j...@brutus%3e Has it been resolved? Or do I have a workaround? Thanks! Regards, Yu Wang
Re: Timestamp in JPQL where clause issue
Hi, Can you please change the parameter name from to something else? The error is during parse and may have be related to the fact that from is a reserved word in JPQL. - Pinaki -- View this message in context: http://n2.nabble.com/Timestamp-in-JPQL-where-clause-issue-tp3332190p550.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
enhancing entity which is a subclass
Everything works with EclipseLink and TopLink but fails with OpenJPA. Tried with runtime as well as build time enhancement. The problem is the entity class is a subclass. In this test case, it is an empty class which inherits everything from the base class UserModelBaseImpl. ... ... ... [openjpac] Caused by: java.io.IOException: org.xml.sax.SAXException: file:/TestCase/build/web/WEB-INF/classes/META-INF/orm.xml [Location: Line: 19, C: 18]: Could not find property/field with the name id in type com.example.model.impl.UserModelImpl.[java.lang.NoSuchMethodException: com.example.model.impl.UserModelImpl.getId()] ... ... ... Caused by: java.lang.NoSuchMethodException: com.example.model.impl.UserModelImpl.getId() at java.lang.Class.getDeclaredMethod(Class.java:1937) at org.apache.openjpa.lib.util.J2DoPrivHelper$8.run(J2DoPrivHelper.java:288) at java.security.AccessController.doPrivileged(Native Method) at org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.parseField(XMLPersistenceMetaDataParser.java:1105) ... 46 more The getId method exists in the parent class. In fact all methods/fields are defined in the parent base implementation. The orm.xml specifies PROPERTY access. Is this is a bug? -- View this message in context: http://n2.nabble.com/enhancing-entity-which-is-a-subclass-tp612p612.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
One-sided @OneToMany
Hi, I'm new to OpenJPA. Just few background words before my first question. My walk to OpenJPA was Hibernate when it was early alpha on persistence with annotations, then CakePHP for the shake of simplicity and now OpenJPA because : * fetch group. I didn't know the name before I read OpenJPA's doc, but I need this and did that by hand before ... I found I won't feel lonely anymore when I read that part of the doc :-) * it is standard * it look really clean * I need more power than CakePHP or Hibernate can provide * I'm more than happy to come back to Java (leaving PHP) on that part :-) So, I have a question on one-sided @OneToMany relationship. Chapter 7.7.7 of the doc handle that case, but I would like to avoid using specific things when possible. Why do I have to use @ElementJoinColumn annotation that apparently (looking to imports) is not from JPA but is part of OpenJPA ? Does it mean that this kind of very common @OneToMany relation is not part of JPA ? Did I use the wrong annotation (@ElementJoinColumn), is there a standard JPA way of doing that ? If an example is needed to explain, let's consider a Command that have many CommandLine. One CommandLine can be under one and only one Command. So this example is typically handled by a one-sided one-to-many relation where we'll found a command_id column in the CommandLine table. Any feedback appreciated ! JBB.
Re: enhancing entity which is a subclass
Can you post snippets of your Entities and your persistence.xml file? -Rick On Mon, Jul 27, 2009 at 7:47 AM, pdd pbar...@gmail.com wrote: Everything works with EclipseLink and TopLink but fails with OpenJPA. Tried with runtime as well as build time enhancement. The problem is the entity class is a subclass. In this test case, it is an empty class which inherits everything from the base class UserModelBaseImpl. ... ... ... [openjpac] Caused by: java.io.IOException: org.xml.sax.SAXException: file:/TestCase/build/web/WEB-INF/classes/META-INF/orm.xml [Location: Line: 19, C: 18]: Could not find property/field with the name id in type com.example.model.impl.UserModelImpl.[java.lang.NoSuchMethodException: com.example.model.impl.UserModelImpl.getId()] ... ... ... Caused by: java.lang.NoSuchMethodException: com.example.model.impl.UserModelImpl.getId() at java.lang.Class.getDeclaredMethod(Class.java:1937) at org.apache.openjpa.lib.util.J2DoPrivHelper$8.run(J2DoPrivHelper.java:288) at java.security.AccessController.doPrivileged(Native Method) at org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.parseField(XMLPersistenceMetaDataParser.java:1105) ... 46 more The getId method exists in the parent class. In fact all methods/fields are defined in the parent base implementation. The orm.xml specifies PROPERTY access. Is this is a bug? -- View this message in context: http://n2.nabble.com/enhancing-entity-which-is-a-subclass-tp612p612.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: enhancing entity which is a subclass
Here are the relevant snippets. persistence.xml fragment - persistence-unit name=UserAdmin transaction-type=RESOURCE_LOCAL !-- Explicitly define mapping file path, else Hibernate won't find the default -- non-jta-data-source/ mapping-fileMETA-INF/orm.xml/mapping-file !-- Prevent annotation scanning. In this app we are purely driven by orm.xml -- exclude-unlisted-classestrue/exclude-unlisted-classes properties/ /persistence-unit persistence-unit name=enhance transaction-type=RESOURCE_LOCAL providerorg.apache.openjpa.persistence.PersistenceProviderImpl/provider classcom.example.model.impl.UserModelImpl/class /persistence-unit Entity class UserModelImpl -- package com.example.model.impl; public class UserModelImpl extends UserModelBaseImpl { } UserModelBaseImpl.java --- package com.example.model.impl; import com.example.model.UserModel; public class UserModelBaseImpl implements UserModel { private long id = -1; private String firstName; private String lastName; private int age; private double wages; private boolean active; public int getAge() { return age; } public String getFirstName() { return firstName; } public long getId() { return id; } ... ... ... public void setAge(int age) { this.age = age; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setId(long id) { this.id = id; } ... ... ... } orm.xml -- persistence-unit-metadata xml-mapping-metadata-complete/ persistence-unit-defaults accessPROPERTY/access /persistence-unit-defaults /persistence-unit-metadata packagecom.example.model.impl/package entity class=UserModelImpl table name=User/ attributes id name=id generated-value strategy=IDENTITY/ /id basic name=firstName/ basic name=lastName/ basic name=age/ basic name=wages/ basic name=active column name=ACTIVE_/ /basic transient name=new/ /attributes /entity Rick Curtis wrote: Can you post snippets of your Entities and your persistence.xml file? -Rick -- View this message in context: http://n2.nabble.com/enhancing-entity-which-is-a-subclass-tp612p3334036.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
JTA and Resouce_Local setup
I have object structure like this in my project. I have a SessionBean around a jpa entity like this. Jpa: Person--Customer---Invoices(Collection)---Data when i run a test on persistence.xml in Resouce_Local it works fine as finding a person returns the entire structure including the collection of invoices. However , the same setup when run in the container does not return all structure it only returns up to Person--Customer. as a result application throws exceptions because of missing data. I am using wasce2.1.1.2 and apache Derby. Jta XA datasource. I am also using container injection of entityManager into sessionBean. Clearly something is wrong with the JTA and why the same persistence.xml will return different results between JTA and Resouce_Local ? Any Ideas? -- View this message in context: http://n2.nabble.com/JTA-and-Resouce_Local--setup-tp3334116p3334116.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: MappingTool create index fails
FIXED: I had to tell H2 not to close with ;DB_CLOSE_DELAY=-1: bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource property name=driverClassName value=org.h2.Driver / property name=url value=jdbc:h2:mem:mypersistence;DB_CLOSE_DELAY=-1 / property name=username value=sa / property name=password value= / /bean Diane J wrote: Using H2 database and Spring for testing: bean id=entityManagerFactory class=org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean property name=persistenceUnitName value=testPersistenceUnit / property name=dataSource ref=dataSource / property name=jpaVendorAdapter bean class=org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter property name=showSql value=true / property name=generateDdl value=true / property name=database value=H2 / /bean /property property name=jpaPropertyMap map entry key=openjpa.SynchronizeMappings value=buildSchema(SchemaAction=add,deleteTableContents,ForeignKeys=true) / entry key=openjpa.Log value=File=stdout, DefaultLevel=TRACE, SQL=TRACE / entry key=openjpa.jdbc.DBDictionary value=org.apache.openjpa.jdbc.sql.H2Dictionary(useGetObjectForBlobs=false) /!-- entry key=openjpa.jdbc.UpdateManager value=operation-order / --entry key=openjpa.ConnectionFactoryProperties value=PrettyPrint=true, PrettyPrintLineLength=72 / /map /property property name=loadTimeWeaver bean class=org.springframework.instrument.classloading.SimpleLoadTimeWeaver / /property /bean Console: 437 testPersistenceUnit TRACE [main] openjpa.jdbc.SQL - t 109577864, conn 1115112055 executing stmnt 2093513928 CREATE TABLE EMPLOYMENT (EMPLOYMENT_ID BIGINT NOT NULL, LST_UPDT_CD VARCHAR(1), LST_UPDT_TMP TIMESTAMP, LST_UPDT_USER_ID BIGINT, CUST_EMP_ID VARCHAR(20), HIRED_DATE DATE, JOB_ID BIGINT, JOB_TITLE VARCHAR(50), ORG_ID BIGINT NOT NULL, ORIG_DATA_SRC VARCHAR(15), PART_TIME_FLAG VARCHAR(1), POSITION_TITLE VARCHAR(35), START_DATE DATE, TERM_DATE DATE, EMP_ID BIGINT NOT NULL, PRIMARY KEY (EMPLOYMENT_ID)) 437 testPersistenceUnit TRACE [main] openjpa.jdbc.SQL - t 109577864, conn 1115112055 [0 ms] spent 437 testPersistenceUnit TRACE [main] openjpa.jdbc.JDBC - t 109577864, conn 1115112055 [0 ms] commit 437 testPersistenceUnit TRACE [main] openjpa.jdbc.JDBC - t 109577864, conn 1115112055 [0 ms] close 453 testPersistenceUnit TRACE [main] openjpa.jdbc.JDBC - t 109577864, conn 897594752 [16 ms] rollback 484 testPersistenceUnit TRACE [main] openjpa.jdbc.SQL - t 109577864, conn 1409963018 executing stmnt 307237456 CREATE INDEX I_MPLYMNT_EMPLOYEE ON EMPLOYMENT (EMP_ID) 484 testPersistenceUnit TRACE [main] openjpa.jdbc.SQL - t 109577864, conn 1409963018 [0 ms] spent 484 testPersistenceUnit TRACE [main] openjpa.jdbc.JDBC - t 109577864, conn 1409963018 [0 ms] close org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Injection of persistence fields failed; nested exception is openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal general error org.apache.openjpa.persistence.PersistenceException: Table EMPLOYMENT not found; SQL statement: CREATE INDEX I_MPLYMNT_EMPLOYEE ON EMPLOYMENT (EMP_ID) [42102-115] {stmnt 714418837 CREATE INDEX I_MPLYMNT_EMPLOYEE ON EMPLOYMENT (EMP_ID) } [code=42102, state=42S02] at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:311) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(AccessController.java:224) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at
Re: enhancing entity which is a subclass
After looking at the spec, it looks like you should be using the mapped-superclass XML descriptor on the UserModelBaseImpl class and com.example.model.impl.UserModelImpl needs to be added to your list of persistent classes. See section 2.11 - 'Inheritance' for more details. Let me know how it goes! -Rick -- View this message in context: http://n2.nabble.com/enhancing-entity-which-is-a-subclass-tp612p3335590.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused
I am getting a very strange error when calling persist/merge on my entity under only one specific case. Basically I have a User entity and a UserProfile Entity. The User entity has a one to one mapping to the UserProfile entity. This is all working fine. I have a Country entity, a Locale entity and Currency entity, all of which I can create,persist,merge with no issues. The problem occurs when I add a many to one relationship to my UserProfile entity for a Country entity. When I persist/merge a User entity, it cascades to its related UserProfile which in turn cascades to its Country entity. So here is the relationship: User -à UserProfile à Country When I call persist/merge on the User entity I get this error: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. That doesnt make any sense because there is no generic class in the entities being saved. To confuse the issue, when I have an empty UserProfile table, I get the same error but the UserProfile does get saved. Later when I try to make a change to the UserProfile on the User and call merge, then I get the same error but the UserProfile is not updated. To confuse things even more, if I add the other two additional entities to UserProfile (currency and locale) then they work just fine. The other two entities are actually the same class as the Country class just renamed. All these classes are defined in my persistence.xml and I can do anything to them (persist/merge) if I use them by themselves, but only under the scenario described above will I get this issue. Does anyone have a clue what might be the issue? I put on trace logging but cant see any insert/update query being executed due to this metadata issue. Here is the full stacktrace: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.ja va:298) at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1114) at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java :268) at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java :451) at com.trm.jpa.services.EntityService.find(EntityService.java:80) at com.trm.beans.backing.UserListBackingBean.countryValueChanged(UserListBackin gBean.java:215) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.el.parser.AstValue.invoke(AstValue.java:131) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(Met hodExpressionValueChangeListener.java:80) ... 31 more 114986 trmPU TRACE [http-8080-1] openjpa.jdbc.JDBC - The batch limit is set to 0. 114995 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 31115924 UPDATE User SET active = ?, createdate = ?, updatedate = ?, name = ?, PROFILE_ID = ? WHERE uniqueid = ? [params=(int) 1, (Timestamp) 2009-07-27 02:13:53.0, (Timestamp) 2009-07-28 06:19:59.464, (String) Christopher Davies, (String) 3051, (String) cndavies] 114996 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 [1 ms] spent 114996 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 4155459 UPDATE UserProfile SET email = ?, fax = ?, mobile = ?, phone = ?, COUNTRY_UNIQUEID = ?, CURRENCY_UNIQUEID = ?, LOCALE_UNIQUEID = ? WHERE id = ? [params=(String) c...@cndavies.com, (String) 02 9356 4557, (String) 0403655872, (String) 02 9356 4557, (String) AL, (String) JPY, (String) en_NZ, (String) 3051] 114999 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 [3 ms] spent 115000 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 27931988 UPDATE User SET active = ?, createdate = ?, updatedate = ?, name = ?, PROFILE_ID = ? WHERE uniqueid = ? [params=(int) 1, (Timestamp) 2009-07-27 02:13:53.0, (Timestamp) 2009-07-28 06:19:59.464, (String) Wandy Rarung, (null) null, (String) wrrarung] 115000 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 [0 ms] spent 115000 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 26426732 UPDATE Locale SET active = ?, createdate = ?, updatedate =
RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused
Hi, What are the values passed inside com.trm.jpa.services.EntityService.find(EntityService.java:80) while calling entitymanager.find() ? Thanks, Ravi. -Original Message- From: C N Davies [mailto:c...@cndavies.com] Sent: Monday, July 27, 2009 2:40 PM To: users@openjpa.apache.org Subject: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused I am getting a very strange error when calling persist/merge on my entity under only one specific case. Basically I have a User entity and a UserProfile Entity. The User entity has a one to one mapping to the UserProfile entity. This is all working fine. I have a Country entity, a Locale entity and Currency entity, all of which I can create,persist,merge with no issues. The problem occurs when I add a many to one relationship to my UserProfile entity for a Country entity. When I persist/merge a User entity, it cascades to it's related UserProfile which in turn cascades to its Country entity. So here is the relationship: User -à UserProfile à Country When I call persist/merge on the User entity I get this error: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. That doesn't make any sense because there is no generic class in the entities being saved. To confuse the issue, when I have an empty UserProfile table, I get the same error but the UserProfile does get saved. Later when I try to make a change to the UserProfile on the User and call merge, then I get the same error but the UserProfile is not updated. To confuse things even more, if I add the other two additional entities to UserProfile (currency and locale) then they work just fine. The other two entities are actually the same class as the Country class just renamed. All these classes are defined in my persistence.xml and I can do anything to them (persist/merge) if I use them by themselves, but only under the scenario described above will I get this issue. Does anyone have a clue what might be the issue? I put on trace logging but can't see any insert/update query being executed due to this metadata issue. Here is the full stacktrace: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.ja va:298) at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1114) at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java :268) at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java :451) at com.trm.jpa.services.EntityService.find(EntityService.java:80) at com.trm.beans.backing.UserListBackingBean.countryValueChanged(UserListBackin gBean.java:215) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.el.parser.AstValue.invoke(AstValue.java:131) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(Met hodExpressionValueChangeListener.java:80) ... 31 more 114986 trmPU TRACE [http-8080-1] openjpa.jdbc.JDBC - The batch limit is set to 0. 114995 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 31115924 UPDATE User SET active = ?, createdate = ?, updatedate = ?, name = ?, PROFILE_ID = ? WHERE uniqueid = ? [params=(int) 1, (Timestamp) 2009-07-27 02:13:53.0, (Timestamp) 2009-07-28 06:19:59.464, (String) Christopher Davies, (String) 3051, (String) cndavies] 114996 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 [1 ms] spent 114996 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 4155459 UPDATE UserProfile SET email = ?, fax = ?, mobile = ?, phone = ?, COUNTRY_UNIQUEID = ?, CURRENCY_UNIQUEID = ?, LOCALE_UNIQUEID = ? WHERE id = ? [params=(String) c...@cndavies.com, (String) 02 9356 4557, (String) 0403655872, (String) 02 9356 4557, (String) AL, (String) JPY, (String) en_NZ, (String) 3051] 114999 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 [3 ms] spent 115000 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 27931988 UPDATE User SET active = ?, createdate = ?, updatedate = ?, name = ?, PROFILE_ID = ? WHERE uniqueid = ? [params=(int)
RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused
Hi Ravi, Here is what gets executed: public Object find(Object co, String uid) { Class clazz = co.getClass(); Object existing = em.find(clazz, uid); return existing; } EM is an instance of the Entity Manager, but since tis code is used everywhere in my code, and the fact that the currency and the locale in the UserProfile use exactly the same code as the Country, it doesn't make sense that the Country entity is the only one giving the issue. Chris -Original Message- From: Ravi Palacherla [mailto:ravi.palache...@oracle.com] Sent: Tuesday, 28 July 2009 6:54 AM To: users@openjpa.apache.org; c...@cndavies.com Subject: RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused Hi, What are the values passed inside com.trm.jpa.services.EntityService.find(EntityService.java:80) while calling entitymanager.find() ? Thanks, Ravi. -Original Message- From: C N Davies [mailto:c...@cndavies.com] Sent: Monday, July 27, 2009 2:40 PM To: users@openjpa.apache.org Subject: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused I am getting a very strange error when calling persist/merge on my entity under only one specific case. Basically I have a User entity and a UserProfile Entity. The User entity has a one to one mapping to the UserProfile entity. This is all working fine. I have a Country entity, a Locale entity and Currency entity, all of which I can create,persist,merge with no issues. The problem occurs when I add a many to one relationship to my UserProfile entity for a Country entity. When I persist/merge a User entity, it cascades to it's related UserProfile which in turn cascades to its Country entity. So here is the relationship: User -à UserProfile à Country When I call persist/merge on the User entity I get this error: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. That doesn't make any sense because there is no generic class in the entities being saved. To confuse the issue, when I have an empty UserProfile table, I get the same error but the UserProfile does get saved. Later when I try to make a change to the UserProfile on the User and call merge, then I get the same error but the UserProfile is not updated. To confuse things even more, if I add the other two additional entities to UserProfile (currency and locale) then they work just fine. The other two entities are actually the same class as the Country class just renamed. All these classes are defined in my persistence.xml and I can do anything to them (persist/merge) if I use them by themselves, but only under the scenario described above will I get this issue. Does anyone have a clue what might be the issue? I put on trace logging but can't see any insert/update query being executed due to this metadata issue. Here is the full stacktrace: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.ja va:298) at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1114) at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java :268) at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java :451) at com.trm.jpa.services.EntityService.find(EntityService.java:80) at com.trm.beans.backing.UserListBackingBean.countryValueChanged(UserListBackin gBean.java:215) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.el.parser.AstValue.invoke(AstValue.java:131) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(Met hodExpressionValueChangeListener.java:80) ... 31 more 114986 trmPU TRACE [http-8080-1] openjpa.jdbc.JDBC - The batch limit is set to 0. 114995 trmPU TRACE [http-8080-1] openjpa.jdbc.SQL - t 7444146, conn 19525584 executing prepstmnt 31115924 UPDATE User SET active = ?, createdate = ?, updatedate = ?, name = ?, PROFILE_ID = ? WHERE uniqueid = ? [params=(int) 1, (Timestamp) 2009-07-27 02:13:53.0, (Timestamp) 2009-07-28 06:19:59.464, (String) Christopher Davies, (String) 3051, (String) cndavies] 114996 trmPU TRACE
RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused
Hi Chris, This exception can be seen if co.getClass() returns Class.class. You can may be print clazz before e.find() to see if it is correct. Once it is confirmed, then we can try to isolate the reason for why co.getClass() returns Class only for a country and not for other entities. Are you getting this exception everytime the following stack trace is traversed ? at com.trm.jpa.services.EntityService.find(EntityService.java:80) at com.trm.beans.backing.UserListBackingBean.countryValueChanged(UserListBackingBean.java:215) Regards, Ravi. -Original Message- From: C N Davies [mailto:c...@cndavies.com] Sent: Monday, July 27, 2009 3:05 PM To: Ravi Palacherla; users@openjpa.apache.org Subject: RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused Hi Ravi, Here is what gets executed: public Object find(Object co, String uid) { Class clazz = co.getClass(); Object existing = em.find(clazz, uid); return existing; } EM is an instance of the Entity Manager, but since tis code is used everywhere in my code, and the fact that the currency and the locale in the UserProfile use exactly the same code as the Country, it doesn't make sense that the Country entity is the only one giving the issue. Chris -Original Message- From: Ravi Palacherla [mailto:ravi.palache...@oracle.com] Sent: Tuesday, 28 July 2009 6:54 AM To: users@openjpa.apache.org; c...@cndavies.com Subject: RE: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused Hi, What are the values passed inside com.trm.jpa.services.EntityService.find(EntityService.java:80) while calling entitymanager.find() ? Thanks, Ravi. -Original Message- From: C N Davies [mailto:c...@cndavies.com] Sent: Monday, July 27, 2009 2:40 PM To: users@openjpa.apache.org Subject: Very weird enhancement error - is the class enhanced or not? - OpenJPA seems confused I am getting a very strange error when calling persist/merge on my entity under only one specific case. Basically I have a User entity and a UserProfile Entity. The User entity has a one to one mapping to the UserProfile entity. This is all working fine. I have a Country entity, a Locale entity and Currency entity, all of which I can create,persist,merge with no issues. The problem occurs when I add a many to one relationship to my UserProfile entity for a Country entity. When I persist/merge a User entity, it cascades to it's related UserProfile which in turn cascades to its Country entity. So here is the relationship: User -à UserProfile à Country When I call persist/merge on the User entity I get this error: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. That doesn't make any sense because there is no generic class in the entities being saved. To confuse the issue, when I have an empty UserProfile table, I get the same error but the UserProfile does get saved. Later when I try to make a change to the UserProfile on the User and call merge, then I get the same error but the UserProfile is not updated. To confuse things even more, if I add the other two additional entities to UserProfile (currency and locale) then they work just fine. The other two entities are actually the same class as the Country class just renamed. All these classes are defined in my persistence.xml and I can do anything to them (persist/merge) if I use them by themselves, but only under the scenario described above will I get this issue. Does anyone have a clue what might be the issue? I put on trace logging but can't see any insert/update query being executed due to this metadata issue. Here is the full stacktrace: openjpa-1.2.0-r422266:683325 nonfatal user error org.apache.openjpa.persistence.ArgumentException: No metadata was found for type class java.lang.Class. The class is not enhanced. at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.ja va:298) at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1114) at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java :268) at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java :451) at com.trm.jpa.services.EntityService.find(EntityService.java:80) at com.trm.beans.backing.UserListBackingBean.countryValueChanged(UserListBackin gBean.java:215) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at
Re: inconsistent SQL's RESOURCE_LOCAL Vrs JTA
Hi, My guess is that the SQL generation should not be different between JTA and RESOURCE_LOCAL. Can you please add default trace level logging to both the scenarios and attach the logs here. That way we can compare between both scenarios and find if there are any differences in the properties between JTA and RESOURCE_LOCAL. You may already know, adding property name=openjpa.Log value=DefaultLevel=TRACE/ to persistence.xml will set the logging level to trace. Regards, Ravi. brobbsnet wrote: please my project runs ok and generate all Sql statements under RESOURCE_LOCAL persistence.xml. when i change to run in the container using JTA , it does not generate the same number on sql statements causing the application to throw exceptions. for example when i run a test under RESOURCE_LOCAL, it prints out this two sql statements as follows. 1. TRACE [main] openjpa.jdbc.SQL - t 1981891711, conn 35138160 executing prepstmnt 1171248050 SELECT t0.PRSN_ID, t1.CUSTOMER_ID,...etc. TRACE [main] openjpa.jdbc.SQL - t 1981891711, conn 35138160 [16 ms] spent 2. ChampAppEJBPU TRACE [main] openjpa.jdbc.SQL - t 1981891711, conn 596825604 executing prepstmnt 1703379623 SELECT t0.INVOICE_ID, t0.EST_WAIVER, etc The same persistence.xml setup on the server using JTA and XA datasource only prints out one statement. TRACE [main] openjpa.jdbc.SQL - t 1981891711, conn 35138160 executing prepstmnt 1171248050 SELECT t0.PRSN_ID, t1.CUSTOMER_ID,...etc. This results in the data from the second sql missing to the application. clearly something is wrong. I am using WASCE (websphere community edition Version 2.1.1.2) and Apache Derby database. Is there something in the JTA configuration that i am missing ? Any thoughts will be appreciated. -- View this message in context: http://n2.nabble.com/inconsistent-SQL%27s-RESOURCE_LOCAL-Vrs-JTA-tp3331934p3336665.html Sent from the OpenJPA Users mailing list archive at Nabble.com.