Announcement Announcement Module
Collapse
No announcement yet.
Composite key integration in RooEntity Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Composite key integration in RooEntity

    Hi all,

    Anyone knows how to solve this please :

    1. I created an Entity with a composite key @RooEntity(identifierType = Pfet_EnumPK.class)

    Code:
    @RooJavaBean
    @RooToString
    @RooEntity(identifierType = Pfet_EnumPK.class)
    public class Pfet_Enum {
     
    	private String libelle_fr;
    
    	private String libelle_en;
    
    }
    2. I created the @RooIdentifier corresponding class for embedding the coposite key in the 1. Entity

    Code:
    @RooToString
    @RooIdentifier
    public class Pfet_EnumPK implements java.io.Serializable {
    
    	private static final long serialVersionUID = 1L;
     
    	@NotNull
    	private String type;
    
    	@NotNull
    	@Size(max = 6)
    	@Column(length = 6)
    	private String code;
    }
    3. Try to use the first entity in a "parent" Entity but get following error:

    Code:
    Caused by: org.hibernate.MappingException: Foreign key (FKF16F841A123B28D6:parent_pfe [pfe])) must have same number of columns as the referenced primary key (pfet_enum [code,type])
    I would say "Yes! you're right", but how can I define multiple columns for embedding my composite Id in this parent Entity?

    The parent entity code is as follow :
    Code:
    @RooJavaBean
    @RooToString
    @RooEntity
    public class ParentPfe {
    	
        @NotNull
        @ManyToOne
        private Pfet_Enum pfe;
    }

    Thanks for your time.
    Last edited by francoismaturel; Jul 19th, 2011, 10:13 AM.

  • #2
    found a solution

    Ok I found a solution. Something like:

    Code:
    @JoinColumns({
    	@JoinColumn(name = "type_foo", referencedColumnName = "type"),
    	@JoinColumn(name = "code_foo", referencedColumnName = "code")
    	})
    private Pfet_Enum foo;
    Seems to do the job!
    Hope it helps
    Last edited by francoismaturel; Jul 20th, 2011, 03:07 AM.

    Comment

    Working...
    X