openjpa-dev mailing list archives

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

     [ https://issues.apache.org/jira/browse/OPENJPA-2157?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kemal Serkan updated OPENJPA-2157:
----------------------------------


NOTE: This occurs only for version 2.0 persistence.xml. Using 1.0 persistence.xml solved the
problem for the sample. Here is the problematic persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
	<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

		<class>openjpa.test.Living</class>
		<class>openjpa.test.Human</class>
	</persistence-unit>
</persistence>
                
> @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.1.1, 2.2.0
>            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