-->
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.  [ 2 posts ] 
Author Message
 Post subject: O/R Mapping v Annotation problem
PostPosted: Fri Apr 01, 2011 5:09 am 
Newbie

Joined: Fri Apr 01, 2011 4:59 am
Posts: 6
Hi,

I have a problem with the mapping files, i have succesfully created the same with annotations but i require to do it with mappings also. Ive searched the forums and googled but i cant find the problem.

I am trying to persist data to an Oracle DB.

The problem I have is around a list of strings, the annotation works fine but the mapping ive found on the docs and elsewhere doesn't work. Here is the code:

Code:
   @CollectionOfElements
   @JoinTable(name="ADDRESS",     
         joinColumns = @JoinColumn(name="CUSTOMER_ADDRESS_ID"))// References parent )
   @Column(name="ADDRESS_LINE", nullable=false)
   private List<String> list;
   


Code:
<list name="list" table="ADDRESS">
   <key column="CUSTOMER_ADDRESS_ID" />
   <list-index column="ID" />
   <element type="string" column="ADDRESS_LINE"/>
</list>


The index column should be the PK of the table that is being referenced is that correct? But basically how do i represent the above annotation in a mapping file?

Thanks for any help!


Top
 Profile  
 
 Post subject: Re: O/R Mapping v Annotation problem
PostPosted: Fri Apr 01, 2011 7:02 am 
Newbie

Joined: Fri Apr 01, 2011 4:59 am
Posts: 6
Ok so the problem only exists in the mapping files because it requires the index-column not to be a unique key. This doesn't make sense to me really as some tables for referential integrity will require a PK.

So a table like this which works perfectly well for annotations wont work for mapping:
Code:
---------------------
|Address                          |
----------------------------
|ID      PK                         |
|CUSTOMER_ADDRESS_ID    |
|ADDRESS_LINE                 |
---------------------------|


needs to become something like this:
Code:
---------------------
|Address                          |
----------------------------
|ID      PK                         |
|CUSTOMER_ADDRESS_ID    |
|ADDRESS_LINE                 |
|myIndexColumn                |
---------------------------|


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.