Enhanced pcNewInstance redundantly clears fields
-------------------------------------------------
Key: OPENJPA-99
URL: https://issues.apache.org/jira/browse/OPENJPA-99
Project: OpenJPA
Issue Type: Bug
Components: kernel
Reporter: Craig Russell
This exception occurs when using an Entity with a not-null requirement for the object id field.
During creation of the Entity via the enhancer-generated method pcNewInstance, the enhancer-generated
method pcClearFields iterates fields and invokes the enhancer-modified setter method with
the Java default value (null for reference types). The user's setter method enforces not-null
values and throws an exception.
I think that there is no need to have the pcNewInstance call the pcClearFields method to set
values for fields that have already been set to their Java default values. In addition to
the not-null requirement (which is not illegal according to the JPA specification) this behavior
also affects performance. Redundantly setting fields is a waste of CPU.
[java] <0|false|0.9.6-incubating> org.apache.openjpa.persistence.PersistenceException:
null
[java] at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:851)
[java] at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:743)
[java] at org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:169)
[java] at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:320)
[java] at pb.adapter.EJB3Adapter.lookupComponent(EJB3Adapter.java:254)
[java] at pb.common.InternalDriver.lookupComponent(InternalDriver.java:322)
[java] at pb.common.InternalDriver.createRelationships(InternalDriver.java:285)
[java] at pb.OCDriver.createRelationships(OCDriver.java:114)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at com.sun.faban.driver.core.AgentThread.timeRun(AgentThread.java:194)
[java] at com.sun.faban.driver.core.AgentThread.run(AgentThread.java:123)
[java] Caused by: java.lang.NumberFormatException: null
[java] at java.lang.Integer.parseInt(Integer.java:415)
[java] at java.lang.Integer.parseInt(Integer.java:497)
[java] at pb.common.Component.pcsetId(Component.java:95)
[java] at pb.common.Component.pcClearFields(Component.java)
[java] at pb.common.Component.pcNewInstance(Component.java)
[java] at org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:117)
[java] at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:247)
[java] at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:327)
[java] at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:252)
[java] at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:108)
[java] at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:54)
[java] at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:870)
[java] at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:828)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|