-->
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.  [ 7 posts ] 
Author Message
 Post subject: @EmbeddableSuperclass, @IdClass and @ManyToOne
PostPosted: Thu Jan 12, 2006 2:05 pm 
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,

PS: I have a testcase file for this, in case this is an hibernate-
annotations issue instead then a Giampaolo's one...
PPSS: I posted this also on the Hibernate Users forum, but probably this
one is closer to the matter. Sorry for the crosspost.

_________________
Giampaolo Tomassoni
Italy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 4:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@ManyToOne is not yet supported on component nor component ids

having a superclass also the PK is really weird, I haven't tested such case

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 4:12 pm 
Beginner
Beginner

Joined: Thu Mar 18, 2004 8:11 am
Posts: 38
Location: Italy
Well, it worked with hbm. And, after all, I don't think it's so weird:

1) you have to bring the very same persisted attributes of the PK into the entity anyway;

2) the Serializeable interface is already implemented in the PK and it makes sense to me to carry it in the entity, too;

3) PK attributes are just, well, entity attributes this way, a feature that @EmbeddedId wouldn't satisfy;

4) this design seems clever to me than having an entity and its pk related only by an attribute.

Does it break any pattern or design?

_________________
Giampaolo Tomassoni
Italy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 5:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I'll need to test, but there is no reason why it should break HA.
I still conceptually prefer @EmbeddedId since the entity is not its own PK.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 8:05 am 
Beginner
Beginner

Joined: Thu Mar 18, 2004 8:11 am
Posts: 38
Location: Italy
I can spare you a testcase by e-mail, if you like.

Thanks,

_________________
Giampaolo Tomassoni
Italy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 10:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
post a runnable version to JIRA but wo the @ManyToOne
Thanks

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 10:29 am 
Beginner
Beginner

Joined: Thu Mar 18, 2004 8:11 am
Posts: 38
Location: Italy
Sorry for this late reply to you, Emmanuel. Somehow, I didn't get an e-mail notice about your message.

I prepared a testcase without the @ManyToOne in the PK class as required, but that way I found jboss to smoothly deploy it.

This probably mean that the problem is somehow related to the @ManyToOne-in-the-pk case, not to the @IdClass thingery.

Do I have to drop a copy of this testcase to JIRA anyway?

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.  [ 7 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.