-->
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.  [ 2 posts ] 
Author Message
 Post subject: [Gelöst] Annotations - Probleme beim Schemagenerieren
PostPosted: Tue Aug 05, 2008 4:53 am 
Newbie

Joined: Mon Aug 04, 2008 9:57 am
Posts: 2
Hibernate version: 3.2.4.sp1

Hallo, Hibernate ist noch etwas neu für mich.
Ich wollte Hibernate für die Datenbankkommunikation benutzen, aber nur Annotations dabei verwenden (also keine .hbm.xml-Dateien). Laut Doku sollte es gehen (=> http://www.manning.com/bauer2/chapter2.pdf)

Folgendes Problem hab ich:
Code:
package access;
import javax.persistence.*;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.Oracle10gDialect;

@Enity
@Table(name="testtable")
public class HibTest {
  @Id @GeneratedValue
  @Column(name="ID")
  private long id;

  @Column(name="DATA")
  private String data;

  // ... getter + setter (hier weggelassen)
  // public konstruktur (hier weggelassen)

  public static void main(String[] args) {
    Configuration cfg = new Configuration();
    cfg.addClass(access.HibTest.class);
    cfg.configure();
    String lines[] = cfg.generateSchemaCreationScript(new Oracle10gDialect());
    for ( int i=0; i<lines.length; ++i) { System.out.println(lines[i]+";"); }
  }
}


ich hab eine log4j.properties File, welches das Loggin ausgibt und ein hibernate.configure file, welches die Datenbank parameter beinhalten (wird eigentlich hier nicht gebraucht).

Das Programm erzeuugt folgenden Output:
Quote:
INFO Enviroment - Hibernate 3.2.4.sp1
INFO Enviroment - loaded properties from resource hibernate.properties : { hier stehen meine Verbindungsdaten, format_sql=true, show_sql=true, hibernate.bytecode.use_reflection_optimizer=false }
INFO Enviroment - Bytecode provider name : cglib
INFO Enviroment - using JDK 1.4 java.sql.Timestamp handling
INFO Configuration - Reading mappings from Resource: access/HibTest.hbm.xml
INFO Configuration - Reading mappings from Resource: access/HibTest.hbm.xml
Exception in thread "main" org.hibernate.MappingNotFoundException: resource access/HibTest.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:533)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:586)
at access.HibTest.main(HibTest.java)

Ich benutze java 1.6.0_06.

Vielleicht könnt Ihr mir einen Tipp geben, wie ich das Hinbekomme.
Danke!


Last edited by chr-spiess on Tue Aug 05, 2008 8:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 8:12 am 
Newbie

Joined: Mon Aug 04, 2008 9:57 am
Posts: 2
okay .. ich habs selber gefunden :

es darf kein org.hibernate.cfg.Configuration Object sein, sondern es muss ein org.hibernate.cfg.AnnotationConfiguration Object sein.

(Funktion ist dann auch nicht addClass, sondern addAnnotatedClass)


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