openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eddie Man (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-348) Composite PK with association
Date Wed, 05 Sep 2007 04:12:45 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524971
] 

Eddie Man commented on OPENJPA-348:
-----------------------------------

Actually, I haven't apply any enhancement on the class.

Here is the output after added the log property:

35  openjpa  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.0.0
159  openjpa  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
340  openjpa  INFO   [main] openjpa.Enhance - Creating subclass and redefining methods for
"[class A, class B]". This means that your application will be less efficient than it would
if you ran the OpenJPA enhancer.
673  openjpa  TRACE  [main] openjpa.Enhance - Enhancing type "class A".
Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal general error> org.apache.openjpa.persistence.PersistenceException:
null
	at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:303)
	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:197)
	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
	at Test.main(Test.java:9)
Caused by: java.lang.NullPointerException
	at org.apache.openjpa.enhance.ManagedClassSubclasser.setDetachedState(ManagedClassSubclasser.java:275)
	at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:213)
	at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:137)
	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.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:287)
	... 6 more

> Composite PK with association
> -----------------------------
>
>                 Key: OPENJPA-348
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-348
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.0.0
>            Reporter: Eddie Man
>
> I got an exception while using a association within a composite PK
> A.java
> ========
> @Entity
> public class A {
> 	@Id
> 	public int id;
> 	
> 	@OneToMany(mappedBy="a", cascade=CascadeType.ALL)
> 	public HashSet<B> bs = new HashSet<B>();
> }
> B.java
> ========
> @Entity
> @IdClass(BPK.class)
> public class B {
> 	
> 	@Id
> 	public int id;
> 	
> 	@Id
> 	@ManyToOne(cascade=CascadeType.ALL)
> 	@JoinColumns({@JoinColumn(name="aid")})
> 	public A a;
> 	
> 	@Basic
> 	public String name;
> }
> BPK.class
> ============
> public class BPK {
> 	
> 	public int id;
> 	
> 	public int a;
> 	@Override
> 	public boolean equals(Object aObj) {
> 		return super.equals(aObj);
> 	}
> 	
> 	@Override
> 	public int hashCode() {
> 		return super.hashCode();
> 	}
> }
> Here is my code for inserting data to db:
> EntityManager manager = Persistence.createEntityManagerFactory("openjpa").createEntityManager();
> EntityTransaction transaction = manager.getTransaction();
> transaction.begin();
> 		
> A a = new A();
> a.id = 1;
> 		
> B b = new B();
> b.id = 2;
> b.a = a;		
> 		
> a.bs.add(b);
> 		
> manager.persist(a);
> transaction.commit();
> manager.close();
> Exception :
> ==============
> Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal general error> org.apache.openjpa.persistence.PersistenceException:
null
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:303)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:197)
> 	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
> 	at Test.main(Test.java:10)
> Caused by: java.lang.NullPointerException
> 	at org.apache.openjpa.enhance.ManagedClassSubclasser.setDetachedState(ManagedClassSubclasser.java:275)
> 	at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:213)
> 	at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:137)
> 	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.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:287)
> 	... 6 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message