openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eddie Man (JIRA)" <>
Subject [jira] Created: (OPENJPA-348) Composite PK with association
Date Tue, 04 Sep 2007 06:56:58 GMT
Composite PK with association

                 Key: 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
public class A {
	public int id;
	@OneToMany(mappedBy="a", cascade=CascadeType.ALL)
	public HashSet<B> bs = new HashSet<B>();

public class B {
	public int id;
	public A a;
	public String name;

public class BPK {
	public int id;
	public int a;

	public boolean equals(Object aObj) {
		return super.equals(aObj);
	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();
A a = new A(); = 1;
B b = new B(); = 2;
b.a = a;;

Exception :
Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal general error> org.apache.openjpa.persistence.PersistenceException:
	at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(
	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
	at Test.main(
Caused by: java.lang.NullPointerException
	at org.apache.openjpa.enhance.ManagedClassSubclasser.setDetachedState(
	at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(
	at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(
	... 6 more

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

View raw message