-->
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.  [ 3 posts ] 
Author Message
 Post subject: FK to Unique field not possible?
PostPosted: Tue Jun 16, 2015 4:51 pm 
Newbie

Joined: Tue Jun 16, 2015 4:45 pm
Posts: 2
A
- @Id int id
- String aName
- String bName - FK not working

B
- @Id int id
- String bName - unique


Can FK reference only to @Id?
How to make this work?


Top
 Profile  
 
 Post subject: Re: FK to Unique field not possible?
PostPosted: Wed Jun 17, 2015 5:15 am 
Newbie

Joined: Mon Apr 30, 2012 2:19 am
Posts: 6
Hi I'm not sure I understand the problem but here something I tried:

class Person : http://pastebin.com/HR9H8atv
is containing a OneToOne relationship with a PersonBiography : http://pastebin.com/CCZiwNaf

That PersonBiography has it's own @Id but the OneToOne is linked by a String name attribute

With a persistence.xml like this: http://pastebin.com/PrZV2T0H

I think it gives what you where trying to do...


Top
 Profile  
 
 Post subject: Re: FK to Unique field not possible?
PostPosted: Wed Jun 17, 2015 10:47 am 
Newbie

Joined: Tue Jun 16, 2015 4:45 pm
Posts: 2
Thank you for response ecor6633, problem solved and was different. For future reference and google search:

Was using Spring Data JPA, OneToMany mappedBy column that you reference to in a foreign @Entity has to be defined as @Column with actual name.
Without reference FK you don't have to put @Column because it will be converted to @Column automatically.


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

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.