-->
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: @ManyToMany with additional variables, help...
PostPosted: Thu Sep 27, 2007 12:00 pm 
Newbie

Joined: Sat Feb 26, 2005 11:45 am
Posts: 13
Location: Stockholm, Sweden
Hi,
Struggling with a problem the hole day and wonder if anyone may have an easy solution..

I have a Customer and Car class with a many-to-many relationship.

pubilc class Customer {
@id
private id;

@ManyToMany
@IndexColumn(name="idx")
private List<Car> cars = new ArrayList<Car>();

@Column
private float discount;
-- getters/setters --
}

pubilc class Car {
@id
-- other variables + getters/setters.
}

This generates a relationtable customer_car with customer, car and idx as variables.
However I would like to have the 'discount' variable from the Customer class to appear in the relation table customer_car as well so I have customer, car, idx and discount in the realation table.

/M





Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

_________________
kmike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 4:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you need to map the association table as an explicit entity and put your property in it.
The many to many will then become a one to many // many to one

_________________
Emmanuel


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.