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: How do I set inverse=true using annotations?
PostPosted: Wed Oct 19, 2005 11:17 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
How do I set inverse=true on OneToMany association using annotations?

this is what my annotations look like:
Code:
   
    @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
    @JoinColumn(name="participant_id",nullable=false,insertable=true)
    @Cascade (value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)


when I run creation logic there is an insert of the owned entity and then update on that owned entity to set the owner's id (see sql_show output below). I remember I used to set inverse=true to get rid of that update before, and I can not find a way to set it with annotations.

Anyone has an idea?

Thanks,
Alex.


Hibernate version:
3.1rc2



Name and version of the database you are using:
Orcale 9i



The generated SQL (show_sql=true):
Hibernate: select tas_seq_timeoff_snapshot.nextval from dual
Hibernate: select tas_seq_timeoff_snapshot.nextval from dual
Hibernate: select tas_seq_timeoff_snapshot.nextval from dual
Hibernate: select tas_seq_timeoff_snapshot.nextval from dual
Hibernate: select tas_seq_timeoff_snapshot.nextval from dual
Hibernate: insert into tas_timeoff_snapshot (version, end_date, start_date, end_personal, end_vacation, start_personal, start_vacation, participant_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into tas_timeoff_snapshot (version, end_date, start_date, end_personal, end_vacation, start_personal, start_vacation, participant_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into tas_timeoff_snapshot (version, end_date, start_date, end_personal, end_vacation, start_personal, start_vacation, participant_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into tas_timeoff_snapshot (version, end_date, start_date, end_personal, end_vacation, start_personal, start_vacation, participant_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into tas_timeoff_snapshot (version, end_date, start_date, end_personal, end_vacation, start_personal, start_vacation, participant_id, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update tas_participant set version=?, name=?, email=?, hire_date=?, pstart_date=?, group_email=?, manager_id=? where id=? and version=?
Hibernate: update tas_timeoff_snapshot set participant_id=? where id=?
Hibernate: update tas_timeoff_snapshot set participant_id=? where id=?
Hibernate: update tas_timeoff_snapshot set participant_id=? where id=?
Hibernate: update tas_timeoff_snapshot set participant_id=? where id=?
Hibernate: update tas_timeoff_snapshot set participant_id=? where id=?


Top
 Profile  
 
 Post subject: Re: How do I set inverse=true using annotations?
PostPosted: Mon Oct 24, 2005 1:20 pm 
Newbie

Joined: Thu Jul 07, 2005 8:10 am
Posts: 6
Location: St. Louis, MO
ashneyde wrote:
How do I set inverse=true on OneToMany association using annotations?


Can you use inverseJoinColumns as mentioned in section 2.2.5.3.3.1. of the Hibernate Annotations online HTML doc? I just searched in the single page HTML for the word "inverse" and that's what came up.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 2:54 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
ashneyde,

you want to use 'mappedBy' . for example if a one customer could have many orders, you might say

@OneToMany(mappedBy="order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)

in Customer.java .


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.