🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.java
1 messages
1 total messages Started by Sebastian Biały Mon, 23 Apr 2012 20:57
Hibernate, annotations i brak hibernate.cfg.xml
#153404
Author: Sebastian Biały
Date: Mon, 23 Apr 2012 20:57
37 lines
2155 bytes
Chcę użyć *wyłacznie* annotations z hibernate, *żadnych* metadanych 
przez xml. Niestety już na starcie dostałem w łeb:

org.hibernate.cfg.Configuration configuration
  = new org.hibernate.cfg.Configuration();
		
java.util.Properties properties = new java.util.Properties();
		
properties.put( org.hibernate.cfg.Environment.DIALECT, 
"org.hibernate.dialect.MySQLDialect" );
properties.put( "hibernate.connection.driver_class", 
"org.mysql.jdbc.Driver" );
properties.put( "hibernate.connection.url", 
"jdbc:mysql://localhost/spam" );
properties.put( "hibernate.connection.username", "foo" );
properties.put( "hibernate.connection.password", "bar" );
properties.put( "hibernate.show_sql", "true" ); 		

configuration
.addAnnotatedClass( org.bad.page.Foo.class )
.setProperties( properties )
.configure()
;

Po tym kawalku kodu dostaje:

Configuring from resource: /hibernate.cfg.xml

Exception in thread "main" org.hibernate.HibernateException: 
/hibernate.cfg.xml not found

Jak to wyłaczyć aby konfiguracja pochodziła wyłacznie z kodu i annotations?

Google czesam od godziny i pełno przykladów z annotations, w których ... 
oczywiście jest hibernate.cfg.xml. Jestem ślepy lub nie potrafie zadać 
pytania googlowi. Teoretycznie nie podaje do configure ściezki ,ale 
configure() bierze ją domyślna :/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads