-->
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: Foreign composite key in @ManyToOne
PostPosted: Thu Jun 09, 2011 12:05 pm 
Newbie

Joined: Thu Jun 09, 2011 11:55 am
Posts: 1
Hi to all,
I Have two entity classes modeling two tables in a legacy DB whose mapping is obtained through a composite key (an integer and a date field). When the system try to update the schema I receive this error:
ERROR [SchemaUpdate] Unsuccessful: alter table N2AX_GIORNATE add constraint FK69E4EA0D7FBE51F4 foreign key (DATA, ID_DIP) references GIORNATE
ERROR [SchemaUpdate] ORA-02267: tipo colonna riferente non compatibile con il tipo colonna riferita

which essentially means that the order of fields of the 'ALTER TABLE ...' statement doesn't match the order of the primary keys fields.
In fact after I tried to run the SQL statement inverting the order of fields as:
alter table N2AX_GIORNATE add constraint FK69E4EA0D7FBE51F4 foreign key (ID_DIP, DATA) references GIORNATE
everything is right.

The fragment of code in java is:

@ManyToOne
@JoinColumns({
@JoinColumn(name="ID_DIP", referencedColumnName="ID_DIP"),
@JoinColumn(name="DATA", referencedColumnName="DATA")
})
public CGPExceptionEvent getConcreteExceptionEvent() {
return concreteExceptionEvent;
}
.
.
.
The order for columns as specified in the annotation above respects the order of fields in the referred table's primary key.
Could anyone give me any suggestion?
Thnaks in advance

Carlo


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.