-->
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: @EmbeddableSuperclass, @IdClass and @ManyToOne
PostPosted: Thu Jan 12, 2006 10:23 am 
Beginner
Beginner

Joined: Thu Mar 18, 2004 8:11 am
Posts: 38
Location: Italy
Hibernate version: 3.1
Hibernate-annotations version: 3.1beta7
Mapping documents: EJB+Hibernate annotations

Dears,

don't know if it is because I'm not supposed to do it, but the following stuff:

Code:
@EmbeddableSuperclass(access = AccessType.FIELD)
public class A_PK implements Serializable {
    @ManyToOne
    @JoinColumn(name = "idB")
    @NotNull
    public B b;

    @ManyToOne
    @JoinColumn(name = "idC")
    @NotNull
    public C c;

    ...

}


@Entity(access = AccessType.FIELD)
@Table(name = "A")
@IdClass(A_PK.class)
public class A extends A_PK {
    @Column(length = 16)
    @NotNull
    public String someText;

    ...
}


@Entity(access = AccessType.FIELD)
@Table(name = "B")
public class B {
    @Id
    public Integer id;

    @OneToMany(mappedBy = "b")
    public Collection<A> as;

    ...
}


@Entity(access = AccessType.FIELD)
@Table(name = "C")
public class C {
    @Id
    public Integer id;

    @OneToMany(mappedBy = "c")
    public Collection<A> as;

    ...
}



causes an:

Quote:
org.hibernate.MappingException: property not found: c on entity A


This happens during the Collection Mapping phase ("processing collection mappings). More precisely, during the:

Quote:
Mapping collection: C.as -> A



I didn't find anything like this in the test cases of my hibernate-annotations.jar and both the ejb-3.0 and hibernate-annotations specs are a bit scarce of hints about how to mimic the old <key-many-to-one> construct with annotations. Also, the kind of error seems to be related to a problem with the @EmbeddableSuperclass thing.

Am I wrong (once more), or the above-shown class setup is supposed to work with hibernate-annotations, maybe sometime in the future?

Regards,

_________________
Giampaolo Tomassoni
Italy


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.