| Summary: | [Unidirectional OneToOne Relationships] eclipselink doesn't understand MapsId=" " | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Gilberto Caetano de Andrade <gilbertoca> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | CLOSED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Gilberto Caetano de Andrade
Closing. Insufficient information. Please a reproducable test case, or details steps to reproduce including relevant class definitions and mapping information. Have you read the community forums topic, especially the Chris Delahunt comment? The fact that an item is discussed on the forum is not sufficient to avoid providing adequate information in a bug report. (and you have not even provided a link) A recreation is ideal, but failing that a detailed description of the situation is still required in the bug report. It should be possible for the person fixing the bug to get the majority of the information required to fix the bug from the bug report. appologies... I see the link, but the above still applies. persistence-2_0-final-spec.pdf:
"If the dependent entity has a single primary key attribute (i.e, the relationship attribute or an attribute that corresponds to the relationship attribute) and the primary key of the parent entity is a simple primary key, the primary key of the dependent entity is a simple primary key of the same type as that of the parent entity (and neither EmbeddedId nor IdClass is specified). In this case, either (1) the relationship attribute is annotated Id, or (2) a separate Id attribute is specified and the relationship attribute is annotated MapsId (and the value element of the MapsId annotation is not specified)."
I'm using second one with orm.xml:
[code]
<entity class="Person">
<!-- CREATE TABLE PERSON (
ID INTEGER NOT NULL,
ADDRESS VARCHAR(100),
NAME VARCHAR(100) NOT NULL,
P_TYPE CHAR(2) NOT NULL, //NATURALPERSON(NP) OR LEGALENTITY(LE)
VERSION SMALLINT NOT NULL
CONSTRAINT PERSON_PKEY PRIMARY KEY (ID)
);
-->
<table name="person"/>
<inheritance strategy="JOINED"/>
<discriminator-column name="p_type" column-definition="CHAR(2)" length="2" discriminator-type="STRING"/>
<attributes>
<id name="id">
<column name="id"/>
<generated-value strategy="AUTO"/>
</id>
<basic name="name">
<column length="100"/>
</basic>
<basic name="address">
<column length="100"/>
</basic>
<version name="version"/>
</attributes>
</entity>
<entity class="Customer">
<!--
CREATE TABLE CUSTOMER (
PERSON_ID INTEGER NOT NULL,
PAYMENT_DAY INTEGER,
CONSTRAINT CUSTOMER_PK PRIMARY KEY (PERSON_ID)
);
-->
<table name="customer"/>
<named-query name="Customer.findAll">
<query>SELECT l FROM Customer l</query>
<!--hint name="javax.persistence.cacheRetrieveMode" value="CacheRetrieveMode.BYPASS"/-->
</named-query>
<named-query name="Customer.deleteById">
<query>DELETE FROM Customer l WHERE l.id = :id</query>
</named-query>
<attributes>
<id name="id">
<column name="person_id"/>
</id>
<basic name="paymentDay">
<column name="payment_day"/>
</basic>
<one-to-many name="vehicles" target-entity="Vehicle" mapped-by="customer"/>
<one-to-one name="person" target-entity="Person" maps-id="">
<join-column name="person_id" referenced-column-name="id" />
</one-to-one>
</attributes>
</entity>
[/code]
Eclipselink complains about it:
[code]
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running park.model.LegalEntityTest
[EL Config]: 2010-05-05 09:33:12.129--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Customer] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.162--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Vehicle] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.169--ServerSession(15020576)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field customer] is being defaulted to: class park.model.Customer.
[EL Config]: 2010-05-05 09:33:12.17--ServerSession(15020576)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field priceTable] is being defaulted to: class park.model.PriceTable.
[EL Config]: 2010-05-05 09:33:12.171--ServerSession(15020576)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field vType] is being defaulted to: class park.model.VehicleType.
[EL Config]: 2010-05-05 09:33:12.172--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.VehicleType] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.173--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Person] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.174--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.LegalEntity] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.177--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.NaturalPerson] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.178--ServerSession(15020576)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.PriceTable] is set to [FIELD].
[EL Config]: 2010-05-05 09:33:12.18--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Customer] is being defaulted to: Customer.
[EL Config]: 2010-05-05 09:33:12.189--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.223--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Vehicle] is being defaulted to: Vehicle.
[EL Config]: 2010-05-05 09:33:12.224--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.225--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.VehicleType] is being defaulted to: VehicleType.
[EL Config]: 2010-05-05 09:33:12.225--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.227--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Person] is being defaulted to: Person.
[EL Config]: 2010-05-05 09:33:12.227--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.241--ServerSession(15020576)--Thread(Thread[main,5,main])--The column name for element [field address] is being defaulted to: ADDRESS.
[EL Config]: 2010-05-05 09:33:12.242--ServerSession(15020576)--Thread(Thread[main,5,main])--The column name for element [field name] is being defaulted to: NAME.
[EL Config]: 2010-05-05 09:33:12.243--ServerSession(15020576)--Thread(Thread[main,5,main])--The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: 2010-05-05 09:33:12.247--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.LegalEntity] is being defaulted to: LegalEntity.
[EL Config]: 2010-05-05 09:33:12.247--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.249--ServerSession(15020576)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.LegalEntity] is being defaulted to: id.
[EL Config]: 2010-05-05 09:33:12.253--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.NaturalPerson] is being defaulted to: NaturalPerson.
[EL Config]: 2010-05-05 09:33:12.254--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-05-05 09:33:12.254--ServerSession(15020576)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.NaturalPerson] is being defaulted to: id.
[EL Config]: 2010-05-05 09:33:12.255--ServerSession(15020576)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.PriceTable] is being defaulted to: PriceTable.
[EL Config]: 2010-05-05 09:33:12.258--ServerSession(15020576)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Info]: 2010-05-05 09:33:12.675--ServerSession(15020576)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872
[EL Fine]: 2010-05-05 09:33:13.256--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.H2Platform
[EL Config]: 2010-05-05 09:33:13.277--ServerSession(15020576)--Connection(27109735)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>H2Platform
user name=> "park"
datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-05-05 09:33:13.28--ServerSession(15020576)--Connection(7245716)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
User: PARK
Database: H2 Version: 1.2.131 (2010-03-05)
Driver: H2 JDBC Driver Version: 1.2.131 (2010-03-05)
[EL Config]: 2010-05-05 09:33:13.281--ServerSession(15020576)--Connection(9715140)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>H2Platform
user name=> "park"
datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-05-05 09:33:13.283--ServerSession(15020576)--Connection(6503761)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
User: PARK
Database: H2 Version: 1.2.131 (2010-03-05)
Driver: H2 JDBC Driver Version: 1.2.131 (2010-03-05)
[EL Severe]: 2010-05-05 09:33:13.361--ServerSession(15020576)--Thread(Thread[main,5,main])--Local Exception Stack:
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-48] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
[COLOR=blue]Exception Description: Multiple writable mappings exist for the field [park.customer.person_id]. Only one may be defined as writable, all others must be specified read-only.
[/COLOR]Mapping: org.eclipse.persistence.mappings.OneToOneMapping[person]
Descriptor: RelationalDescriptor(park.model.Customer --> [DatabaseTable(park.customer)])
Runtime Exceptions:
---------------------------------------------------------
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:620)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
at park.model.LegalEntityTest.initEntityManager(LegalEntityTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
[/code]
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |