-->
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: Problem mit Vererbung und @Id
PostPosted: Thu Jan 17, 2008 6:56 pm 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Hi, ich habe folgendes Problem. Wie kann ich Hibernate sagen, das der Primärschlüssel in der Oberklasse deklariert ist? Wenn ich XML-Mapping verwende klappt es wunderbar, jetzt mit Annotation leider nicht mehr.

Ich möchte die Vererbung nicht auflösen und auch keine extra Tabelle für DBObject anlegen.

Klassen:
Code:
public abstract class DBObject {
// ...

@Id()
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID")
private int id;

final int getId() { return this.id; }

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

// ...
}


Code:
@Entity
@Table(name="MEASURE")
public final class Measure extends DBObject {
// ...

// ...
}


Wenn ich das Entity Annotation in DBObject verwende, meckert er das es keine Tabelle DBObject gibt. So wie ich den Code gepostet habe meckert er, das in Measure kein Primärschlüssel gefunden wurde.

Danke im voraus :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 2:39 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Die Annotation Inheritance fehlt bei der Parent Klasse.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 4:32 pm 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Die Annotation @javax.persistence.MappedSuperclass hat mein Problem gelöst.

THX @LaLiLuna


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.