-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem beim Component Mapping
PostPosted: Thu Jul 19, 2007 2:48 am 
Beginner
Beginner

Joined: Wed Jul 18, 2007 6:13 am
Posts: 28
Hallo

Ich habe ein Problem beim Component Mapping.
Um es zu verdeutlichen habe ich das Beispiel aus der Hibernate-Doku genommen. Ich möchte jetzt nicht nur bei Person eine automatisch erzeugte Sequenz haben, sondern auch bei Country. Ich habe die Klasse Country um die Annotation @Entity und @GeneratedValue und SequenceGenerator erweitert. Wenn ich jetzt jedoch mit Hilfe von HBM2DDL mir die Tabellen erzeugen lassen möchte, dann wird immer nur die Sequenz SEQ_COUNTRY erzeugt, aber nie SEQ_PERSON.
Weiß jemand vielleicht woran das liegt? Sitze nämlich schon ziemlich lange an diesem Problem :-(

[b]Person.java[/b]

@Entity
@Table(name="PERSON")
public class Person implements Serializable{

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenz")
@SequenceGenerator(name = "sequenz", sequenceName = "SEQ_PERSON", initialValue = 1, allocationSize = 1)
@Column(name="PERSON_ID")
int id;

@Embedded
@AttributeOverrides( {
@AttributeOverride(name="iso2", column = @Column(columnDefinition = "VARCHAR2()", name="bornIso2", length=20) ),
@AttributeOverride(name="name", column = @Column(name="bornCountryName") )
} )
Country bornIn;

public Country getBornIn() {
return bornIn;
}

public void setBornIn(Country bornIn) {
this.bornIn = bornIn;
}

}




[b]Country:[/b]

@Entity
@Embeddable
public class Country implements Serializable {
private String iso2;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenz")
@SequenceGenerator(name = "sequenz", sequenceName = "SEQ_COUNTRY", initialValue = 1, allocationSize = 1)
@Column(name="COUNTRY_ID")
int id;

@Column(name = "countryName")
private String name;

public String getIso2() {
return iso2;
}

public void setIso2(String iso2) {
this.iso2 = iso2;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}


[b]Ergebnis:[/b]

[hibernatetool] create table Country (COUNTRY_ID number(10,0) not null, iso2 varchar2(255 char), countryName varchar2(255 char), primary key (COUNTRY_ID));
[hibernatetool] create table PERSON (PERSON_ID number(10,0) not null, COUNTRY_ID number(10,0) not null, bornIso2 VARCHAR2(), bornCountryName varchar2(255 char), primary key (COUNTRY_ID));
[hibernatetool] create sequence SEQ_COUNTRY;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.