-->
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: Annotation problem with entity hierarchy
PostPosted: Wed Jan 26, 2005 5:45 pm 
Beginner
Beginner

Joined: Sat Jan 17, 2004 5:35 am
Posts: 25
Location: Birmingham, UK
Not sure if this is according to the EJB3 spec or not..

Running the following code with annotations alpha 2:

Code:
import javax.ejb.Entity;
import javax.ejb.Id;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class Test
{
   public static class TestId
   {
      private Long id;

      public Long getId()
      {
         return id;
      }
      
      public void setId(Long id)
      {
         this.id = id;
      }
   }

   @Entity
   public static class TestEntity extends TestId
   {
      @Id
      public Long getId()
      {
         return super.getId();
      }
   }

   public static void main(String[] args)
   {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(TestEntity.class);
      SessionFactory factory = config.buildSessionFactory();
   }
}


Results in the exception:

Code:
org.hibernate.MappingException: Repeated column in mapping for entity: Test$TestEntity column: id (should be mapped with insert="false" update="false")


It obviously works fine if @Id is declared on TestId and not overridden in TestEntity, but this seems to be a problem common to any persistent property with an overridden accessor.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 8:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
outch! This one will be hard to fix properly, and the spec has to clarify some points.
Open an issue to JIRA (HibernateExt/annotations)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 9:15 am 
Beginner
Beginner

Joined: Sat Jan 17, 2004 5:35 am
Posts: 25
Location: Birmingham, UK
Added issue:

http://opensource.atlassian.com/project ... wse/HBX-90

Naively, can't the topmost overridden method be used and the others ignored?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 9:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Year, this is a good rule, but it has to be stated. Plus I do check the property of the super classes of the top most entity, but this is not specified by the spec.
... and this rule is a pain to implement

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 9:44 am 
Beginner
Beginner

Joined: Sat Jan 17, 2004 5:35 am
Posts: 25
Location: Birmingham, UK
IMO, the EJB annotations to be used for a property should be those declared against the accessor used for normal invocation, but I'll let you guys battle it out with the spec.. :)


Top
 Profile  
 
 Post subject: Re: Annotation problem with entity hierarchy
PostPosted: Thu Dec 20, 2012 11:18 pm 
Newbie

Joined: Thu Dec 20, 2012 11:11 pm
Posts: 6
I know this is a lame question, but where's the vote for issue button in jira?!


Top
 Profile  
 
 Post subject: Re: Annotation problem with entity hierarchy
PostPosted: Fri Dec 21, 2012 1:24 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Johnson02 wrote:
I know this is a lame question, but where's the vote for issue button in jira?!


Is it related to this thread? then you can't vote as the issue is solved (and long ago.. please check dates of the forum threads you read)
Normally, you need to be logged in and (create an account) then there is a button on the right panel.

_________________
Sanne
http://in.relation.to/


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