openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kemal Serkan (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (OPENJPA-2157) @SecondaryTable configuration does not handle @ManyToOne foreign keys properly
Date Tue, 20 Mar 2012 13:01:39 GMT
@SecondaryTable configuration does not handle @ManyToOne foreign keys properly
------------------------------------------------------------------------------

                 Key: OPENJPA-2157
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2157
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa, tooling
    Affects Versions: 2.2.0, 2.1.1
            Reporter: Kemal Serkan


@ManyToOne @JoinColumn(name = "f_key", table = "SEC_TABL") schema tool ignores the name specified,
auto-generate a name for the join column. Worse, when deleting the entity, NPE is thrown.
There may also other effects. Here is the NPE stack trace in 2.2.0 version. 

Caused by: java.lang.NullPointerException
	at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.delete(RelationFieldStrategy.java:412)
	at org.apache.openjpa.jdbc.meta.FieldMapping.delete(FieldMapping.java:704)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.delete(AbstractUpdateManager.java:287)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:166)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:95)
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:713)
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	at org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2174)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1843)
	... 39 more

Sample Entities (Only relevant parts, HUMAN table won't have mother_id and father_id but auto-generated
MOTHER_RECORD_ID and FATHER_RECORD_ID):
----------------------------

@javax.persistence.Entity
@Table(name = "LIVING")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype")
public class Living {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "record_id")
	private long systemId = 0L;
	
	@Version
	@Column(name = "version")
	private long version = 0;
}

@javax.persistence.Entity
@SecondaryTable(name = "HUMAN", pkJoinColumns = @PrimaryKeyJoinColumn(name = "record_id"))
public class Human extends Living {
	
	@ManyToOne
	@JoinColumn(name = "mother_id", table = "HUMAN")
	private Human mother;
	
	@ManyToOne
	@JoinColumn(name = "father_id", table = "HUMAN")
	private Human father;
}




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message