Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311282 - One-to-one association from embeddable to entity problems when classes are in individual Java class files
Summary: One-to-one association from embeddable to entity problems when classes are in...
Status: CLOSED INVALID
Alias: None
Product: Gemini.JPA
Classification: RT
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Michael Keith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-01 09:55 EDT by Abdelmonaim Remani CLA
Modified: 2010-12-06 11:02 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Abdelmonaim Remani CLA 2010-05-01 09:55:21 EDT
Build Identifier: M20090917-0800

I followed example 3 on the JEE6 documentation http://java.sun.com/javaee/6/docs/api/javax/persistence/OneToOne.html for One-to-one association from an embeddable class to another entity, and get mapping errors on Eclipse:
http://www.freeimagehosting.net/uploads/d228a72d60.png

If I put all three classes in the same Java file, the errors go away. Please help!
---------------------------------------------------
Here is the persistance.xml file:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" 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_1_0.xsd"> 
<persistence-unit name="JPA_3"> 
<provider>org.hibernate.ejb.HibernatePersistence</provider> 

<class>com.test.Employee</class> 
<class>com.test.LocationDetails</class> 
<class>com.test.ParkingSpot</class> 

<properties> 
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
<property name="hibernate.hbm2ddl.auto" value="create-drop"/> 

<property name="hibernate.show_sql" value="true" /> 
<property name="hibernate.format_sql" value="true" /> 

<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> 
<property name="hibernate.connection.username" value="root"/> 
<property name="hibernate.connection.password" value="root"/> 
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/test_db"/> 
</properties> 
</persistence-unit> 
</persistence> 

---------------------------------------------------
Here are the entity classes: 
---------------------------------------------------
In Employee.java

package com.test; 

import javax.persistence.Embedded; 
import javax.persistence.Entity; 
import javax.persistence.Id; 

@Entity 
public class Employee { 
@Id int id; 
@Embedded LocationDetails location; 
}

---------------------------------------------------
In LocationDetails.java

package com.test; 

import javax.persistence.Embeddable; 
import javax.persistence.OneToOne; 

@Embeddable 
public class LocationDetails { 

int officeNumber; 
@OneToOne ParkingSpot parkingSpot; 

}

---------------------------------------------------
In ParkingSpot.java
Code:
package com.test; 

import javax.persistence.Entity; 
import javax.persistence.Id; 
import javax.persistence.OneToOne; 

@Entity 
public class ParkingSpot { 
@Id int id; 
String garage; 
@OneToOne(mappedBy="location.parkingSpot") Employee assignedTo; 
}

Reproducible: Always

Steps to Reproduce:
1.Create JPA Project
2.Import necessary libs
3.Create an entity class Employee in Employee.java and declare it in persistence.xml as indicated in the details
4.Create an embedable class LocationDetails in LocationDetails.java and declare it in persistence.xml as indicated in the details
5.Create an entity class ParkingSpot in ParkingSpot.java and declare it in persistence.xml as indicated in the details

N.B. The errors (See http://www.freeimagehosting.net/uploads/d228a72d60.png) only appear if the three classes are in in individual Java src files. They go away when all three classes are in one src file.
Comment 1 Michael Keith CLA 2010-05-11 16:22:07 EDT
You entered a bug in Gemini JPA, which is a modular implementation of JPA (using EclipseLink) but it looks like you are using Hibernate as a JPA provider. Please 
enter a bug in the Hibernate bug system, or change providers to EclipseLink and see if this fixes your problem.
Comment 2 Michael Keith CLA 2010-12-06 11:02:41 EST
Moving to correct bin.