-->
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.  [ 11 posts ] 
Author Message
 Post subject: Hibernate 3.1 does not inherited @Id property
PostPosted: Mon Jul 25, 2005 10:18 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2003 6:43 am
Posts: 33
I change to hibernate 3.1 beta1 and hibernate-annotation 3.1 beta 2
now all my class that inherits from my BaseClass gime me an error

No identifier specified for entity: easysolution.persistence.hibernate.model.<My Class>

My BaseClass declare a property as

@Id(generate = GeneratorType.AUTO)
private long id;

and with hibernate 3.0 all is right

what's happened?
it's a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 12:23 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Can you post your BaseClass and Subclass? What kind of Inheritance mapping are you using?


Here's an example of doing JOINED SUBCLASS Inheritance. In the following case, there exists only one table called SubClass


Class BaseClass {

@Id(generate=GeneratorType.AUTO)

private Long Id;
...
}

@Entity(/*access=AccessType.PROPERTY*/)
@org.hibernate.annotations.Entity(selectBeforeUpdate = false,
dynamicInsert = true,
dynamicUpdate = true,
optimisticLock = OptimisticLockType.VERSION )

@Table(name="SUB_CLASS")
@Inheritance(strategy = InheritanceType.JOINED)
Class SubClass extends BaseClass {
}

It works for me in both the previous version and 3.1 beta1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 12:24 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Oops just a typo.

The table name is SUB_CLASS.


Top
 Profile  
 
 Post subject: This are my classes
PostPosted: Tue Jul 26, 2005 12:32 am 
Beginner
Beginner

Joined: Tue Oct 28, 2003 6:43 am
Posts: 33
@Entity(access = AccessType.FIELD)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name = "type")
public abstract class PDataObject implements Serializable {

@Id(generate = GeneratorType.AUTO)
private long id;

@Column(length = 128, nullable = false)
private String eid;

.....





public abstract class PPrincipal extends PDataObject {

public PPrincipal() {
super();
}



......




@Entity(access = AccessType.FIELD)
public class PUser extends PPrincipal {

@Column(length = 32)
String firstName;

@Column(length = 32)
String lastName;


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:06 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Here's what i tried to compile and it just worked! I think you are missing @Entity for PPrincipal class.


@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name = "type")
public abstract class BaseTest {
@Id(generate = GeneratorType.AUTO)
private long id;

@Column(length = 128, nullable = false)
private String eid;
}

@Entity
public abstract class BasePrincipal extends BaseTest {
}

@Entity
public class BaseUser extends BasePrincipal {
@Column(length = 32)
String firstName;

@Column(length = 32)
String lastName;
}


Hope this helps!


Top
 Profile  
 
 Post subject: Yes
PostPosted: Tue Jul 26, 2005 1:16 am 
Beginner
Beginner

Joined: Tue Oct 28, 2003 6:43 am
Posts: 33
You are right :)

With 3.0 it works but I think was that the bug. Now is more correct to sign olso the Principal as @Entity.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:17 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
I'm glad it works.

Please rate the reply if worked :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The notion of @EmbeddedSuperclass has been added, please read the reference documentation for more information

_________________
Emmanuel


Top
 Profile  
 
 Post subject: No I THINK it's a BUG
PostPosted: Wed Aug 03, 2005 5:11 am 
Beginner
Beginner

Joined: Tue Oct 28, 2003 6:43 am
Posts: 33
I create these classes:


@EmbeddableSuperclass(access = AccessType.FIELD)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name = "classType")
public abstract class _DataObject implements Serializable {

@Id(generate = GeneratorType.AUTO)
private long id;

@Column(nullable = false)
private String classType = this.getClass().getName();

public String getClassType() {
return classType;
}

public void setClassType(String classType) {
this.classType = classType;
}

public long getId() {
return id;
}

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

}





@EmbeddableSuperclass(access = AccessType.FIELD)
@Table(name = "Principal")
public abstract class Principal extends _DataObject {

@ManyToOne
private Group parentPrincipal;

public Group getParentPrincipal() {
return parentPrincipal;
}

public void setParentPrincipal(Group parentPrincipal) {
this.parentPrincipal = parentPrincipal;
}

}





@Entity(access = AccessType.FIELD)
public class User extends Principal {

@Column(nullable = false)
private String username;

private String password;

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

}






@Entity(access = AccessType.FIELD)
public class Group extends Principal {

@OneToMany
private Set<Principal> principals = new TreeSet<Principal>();

public Set<Principal> getPrincipals() {
return principals;
}

public void setPrincipals(Set<Principal> principals) {
this.principals = principals;
}

}




and DON'T WORK!!!!!!

with

hibernate-annotations-3.1beta3.zip
hibernate-3.1beta1.zip

why :( ????


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 10:18 am 
Newbie

Joined: Mon Aug 01, 2005 7:33 am
Posts: 18
Location: UK
I think the Hibernate team actually advise you to carry on using the alpha version and NOT to upgrade to the Beta release if you are using Annotations/Entity Manager. And I quote:

"If you use Hibernate Annotations and/or Hibernate EntityManager, please continue using the 3.1 alpha 1 release. An update is already in the works. Use Hibernate 3.1 beta 1 in non-critical development as an update of 3.0.5."

...maybe that is for a reason? Just thought this could save you time rooting for a solution - go back to the alpha. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 7:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
annotations 3.1beta4 n ow work with hibernate beta1

_________________
Emmanuel


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