-->
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.  [ 1 post ] 
Author Message
 Post subject: Multirelation on same entity and strange thing
PostPosted: Thu Jun 07, 2012 6:50 am 
Newbie

Joined: Thu May 05, 2011 6:33 am
Posts: 16
Hi everybody.

I use spring 3.1.Release, with Hibernate 3.2.1, annotation 3.3.0.ga
I have the following hieracy.

Code:
@Entity
public class Property implements Serializable {

   private static final long serialVersionUID = 6817800702395453171L;

   @Id
   Long id;

   String name;

   @ManyToMany
   //@JoinColumns({ @JoinColumn(name = "propertyAction_id"), @JoinColumn(name = "propertyAction_type") })  --> I try to solve  my prolbem whit @JoinColumns
   List<Trasformation> trasformationList = new ArrayList<Trasformation>();

   @ManyToMany
   //@JoinColumns({ @JoinColumn(name = "propertyAction_id", referencedColumnName = "id"),
   //      @JoinColumn(name = "propertyAction_type", referencedColumnName = "type") })
   List<Validation> validationList = new ArrayList<Validation>();

   @ManyToMany
   //@JoinColumns({ @JoinColumn(name = "propertyAction_id", referencedColumnName = "id"),
//         @JoinColumn(name = "propertyAction_type", referencedColumnName = "type") })
   List<Rule> ruleList = new ArrayList<Rule>();

..getter , setter, equals, toString, hashCode
}



Code:
@Entity
@DiscriminatorValue("trasformation")
public class Trasformation extends PropertyAction {

   private static final long serialVersionUID = 3584615686231696769L;
}


Code:

@Entity
@DiscriminatorValue("validation")
public class Validation extends PropertyAction {

   private static final long serialVersionUID = 8753530871622916273L;

}


Code:

@Entity
@DiscriminatorValue("rule")
public class Rule extends PropertyAction {

   private static final long serialVersionUID = 2165118757521500208L;
}


Code:
@Entity
@DiscriminatorColumn(name = "type")
public abstract class PropertyAction implements Serializable {

   private static final long serialVersionUID = 8675454718412016262L;

   @Id
   Long id;

   @Column(insertable = false, updatable = false)
   protected String type;

   String name;

   String beanName;

   @OrderBy
   Integer order;

..getter , setter, equals, toString, hashCode




The table of relathionship between Property and Rule , Validation and Trasformation has 4 column, one per type id.
Property_PropertyAction has
property_id
validationList_id
ruleList_id
trasformationList_id

Is it possible to have this table in this way,

property_id
type --> which is the discriminator column between all type
actionProperty_id

which i think is more readable?

Moreover, when i start my application, the table actionProperty is not create, but if i create the field are added corretly.

I don't know what happen!!! I use the same structure for another entity which, when I ran in update mode on my db, is correctly created. This is not a problem by I am really curious about it!

_________________
Luca Preziati


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

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.