-->
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.  [ 3 posts ] 
Author Message
 Post subject: MappedSuperclass and Access
PostPosted: Tue Aug 16, 2011 6:27 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
What is the expected behavior in this scenario?

Mapped superclass:

Code:
@Access(AccessType.FIELD)
@MappedSuperclass
public class A {

  private long id;

  @Access(AccessType.PROPERTY)
  @Id
  @GeneratedValue
  @Column(name = "id")
  public long getId() {
    return this.id;
  }

  protected void setId(final long id) {
    this.id = id;
  }

}


Entity:

Code:
@Entity
@Table(name = "b")
/* etc. */
public class B extends A {

  @Column(name = "long_description")
  private String longDescription;

  public String getLongDescription() {
    return this.longDescription;
  }

  public void setLongDescription(final String d) {
    this.longDescription = d;
  }

}


I am seeing behavior in Hibernate 3.6.6.Final that seems to suggest that the setter for the longDescription property is being called/used rather than the field.

I was under the impression from the JPA 2.0 specification that if the mapped superclass has @Access(AccessType.FIELD) on it, and then selectively overrides certain getters with @Access(AccessType.PROPERTY) that its children would continue to use the default (AccessType.FIELD). But Hibernate is telling me, for example, that the LONGDESCRIPTION column cannot be found--which would only be the case if it were defaulting the column mapping to LONGDESCRIPTION, and it would only default it if it were using the getters and setters here.

Thanks for any clarification.

Best,
Laird


Top
 Profile  
 
 Post subject: Re: MappedSuperclass and Access
PostPosted: Wed Aug 17, 2011 11:51 am 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
Bug filed with test case demonstrating JPA 2.0 specification violation (confirmed with EclipseLink guys): https://hibernate.onjira.com/browse/HHH-6581

Best,
Laird


Top
 Profile  
 
 Post subject: Re: MappedSuperclass and Access
PostPosted: Wed Aug 17, 2011 11:57 am 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
Just confirmed that the bug exists in Hibernate 4.0.0.Beta4 as well.

Best,
Laird


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.