-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with finding sequence while opening session
PostPosted: Tue May 20, 2014 3:38 am 
Newbie

Joined: Tue May 20, 2014 3:18 am
Posts: 2
Hallo,
Ich bin ein Neueinsteiger bei Hibernate. Ich benutze Netbeans 8.0 und Postgersql 9.0. Ich habe eine Datenbank mit 2 einfachen Tabellen erstellt, beide haben ein Primärschlüssel. Für den Schlüssel benutze ich folgende Annotation:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "artists_artistid_seq")

@Column(name = "artistid", unique = true, nullable = false)
public int getArtistid() {
return this.artistid;
}

Die Sequenz existiert in der Datenbank. Wenn ich aber die Methode openSession aufrufe, dann kriege ich eine Exception mit folgender Meldung:

"Initial SessionFactory creation failed.org.hibernate.AnnotationException: Unknown Id.generator: public.artists_artistid_seq"

Vielen Dank für jeden Tip

Rafal Ziolkowski


Top
 Profile  
 
 Post subject: Re: Problem with finding sequence while opening session
PostPosted: Tue May 20, 2014 5:35 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Du brauchst noch eine Annotation an der Klasse, die den Sequenz-Namen mit einem Generator-Namen verknüpft.

In deinem Fall würde das so aussehen:

Code:
@Entity
@Table...
@SequenceGenerator(sequenceName = "artists_artistid_seq", name = "artists_id_gen")
public class Xyz {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "artists_id_gen")

@Column(name = "artistid", unique = true, nullable = false)
public int getArtistid() {
return this.artistid;
}

..
}


Top
 Profile  
 
 Post subject: Re: Problem with finding sequence while opening session
PostPosted: Tue May 20, 2014 5:52 am 
Newbie

Joined: Tue May 20, 2014 3:18 am
Posts: 2
Ja, das funktioniert jetzt!

Vielen Dank

Rafal Ziolkowski


Top
 Profile  
 
 Post subject: Re: Problem with finding sequence while opening session
PostPosted: Sat Oct 25, 2014 2:48 am 
Newbie

Joined: Sat Oct 25, 2014 2:40 am
Posts: 1
Ich versuche eine Tabelle uber 70 Tausend Datensazt zu lesen und in eine ArrayList zu speichern,aber ich bekomme leider am ende ein :
java.lang.OutOfMemoryError: Java heap space und die performance ich auch sehr schlecht 4 Min lese Zeit

__________
adil


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