openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kemal Serkan (Created) (JIRA)" <>
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
             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(
	at org.apache.openjpa.jdbc.meta.FieldMapping.delete(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.delete(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(
	at org.apache.openjpa.datacache.DataCacheStoreManager.flush(
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(
	at org.apache.openjpa.kernel.BrokerImpl.flush(
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
	at org.apache.openjpa.kernel.BrokerImpl.flush(
	... 39 more

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

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

@SecondaryTable(name = "HUMAN", pkJoinColumns = @PrimaryKeyJoinColumn(name = "record_id"))
public class Human extends Living {
	@JoinColumn(name = "mother_id", table = "HUMAN")
	private Human mother;
	@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:!default.jspa
For more information on JIRA, see:


View raw message