Hi, I am using Hibernate 4.3.5 with Firebird 2.5 and I am facing a problem with a oneToMany association with the annotation @MapKey I guess.
Here are my entities:
@Entity @SequenceGenerator( name = "configDataIdGen", sequenceName = "SEQUENCE_TABLE" ) public class TRM_ConfigData {
/** * The persistence identifier */ @Id @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "configDataIdGen" ) @Column( name = "id", nullable = false, updatable = false ) private long id;
/** * Map of streams (key=stream boid, value=stream) */ @OneToMany( cascade = { CascadeType.ALL }, orphanRemoval = true ) @JoinTable( name = "CONFIG_STREAM", joinColumns = @JoinColumn, inverseJoinColumns = @JoinColumn( name = "STREAM_ID" ) ) @MapKey( name = "m_boid" ) private Map<String, TRM_Stream> m_boidToStream = new HashMap<String, TRM_Stream>();
....
@Entity @PrimaryKeyJoinColumn( name = "id" ) public class TRM_Stream extends TRM_Resource {
}
@Entity @PrimaryKeyJoinColumn( name = "id" ) public abstract class TRM_Resource extends B_ManagedBusinessObject implements Cloneable, Comparable {
}
@Entity @SequenceGenerator( name = "managedBusinessObjectIdGen", sequenceName = "SEQUENCE_TABLE" ) @Inheritance( strategy = InheritanceType.JOINED ) public abstract class B_ManagedBusinessObject extends XmlObjectIdentifier implements BoidInterface, Serializable {
/** * The persistence identifier */ @Id @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "managedBusinessObjectIdGen" ) @Column( name = "id", nullable = false, updatable = false ) private long id;
/** * from the property name (see get and set) then this property will not be exportable by xml. */ protected String m_boid;
When I run my application, I have the following error:
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error SQL error code = -206 Column unknown A1.M_BOID At line 1, column 111
The logging SQL is a bit strange:
Hibernate: select m_boidtost0_.TRM_ConfigData_id as TRM_Conf1_6_0_, m_boidtost0_.STREAM_ID as STREAM_I2_4_0_, (select a1.m_boid from TRM_Stream a1 where a1.id=m_boidtost0_.STREAM_ID) as formula0_0 ......
Hibernate seems to search for the attribute m_boid in the class TRM_Stream where as this attrribute belongs to its parent class B_ManagedBusinessObject.
So my question are : When the key in a map is not a primary key, should the attribute necessary be an attribute of the entity ? Why Hibernate does not detect that this attribute belongs to the parent abstract class ?
Thanks for your help Benoit
|