-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with the use of @mapKey with oneToMany association
PostPosted: Thu Apr 17, 2014 4:24 am 
Newbie

Joined: Thu Apr 17, 2014 3:35 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.