-->
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: how to do ... with annotations?
PostPosted: Fri Oct 27, 2006 1:53 am 
Newbie

Joined: Mon Aug 07, 2006 2:44 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Name and version of the database you are using: mysql 5

i have entity Calendar and many-to-many table CalendarLinkedToCalendar (datatbase generated by external tool, not hibernate!)
im using annotations

i want to map two collections to Calendar object : linkedTo (calendars that this calendar referes) and LinkedFrom (calendars from wich this calendar reffered)

without annotations its simple


Quote:
<set name="linkedToCalendars" table="CalendarLinkedToCalendar" lazy="false">
<key column="idCalendarFK"></key>
<many-to-many class="org.domain.entity.Calendar" column="idCalendarFK_2" />
</set>

<set name="linkedFromCalendars" table="CalendarLinkedToCalendar" lazy="false">
<key column="idCalendarFK_2"></key>
<many-to-many class="org.domain.entity.Calendar" column="idCalendarFK" />
</set>


i need to do the same but with annotations ...
i really dont know how ... help )

p.s. it is possible to specify name of assotiations table (CalendarLinkedToCalendar) with annotations?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 4:18 am 
Newbie

Joined: Mon Aug 07, 2006 2:44 am
Posts: 8
if someone will need it.. solution is:

quote from annotation docks:
Quote:
@OneToMany
@JoinTable(
name="TrainedMonkeys",
joinColumns = { @JoinColumn( name="trainer_id") },
inverseJoinColumns = @JoinColumn( name="monkey_id")
)

and

@OneToMany
@JoinTable(
name="TrainedMonkeys",
joinColumns = { @JoinColumn( name="monkey_id") },
inverseJoinColumns = @JoinColumn( name="trainer_id")
)



pretty simple :)

i like hibernate :)


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.