G/değiştirmek oluşturmak ne tablolar konsolunda görüntülemek için SchemaUpdate kullanarak bir ana yöntem ettik ve bu benim hazırda projesinde çalışıyor: Ben JPA projesinde bu kodu yeniden kullanmak istediğinizHazırda bekletme SchemaUpdate sınıfı bir JPA persistence.xml ile nasıl kullanılır?
public static void main(String[] args) throws IOException {
//first we prepare the configuration
Properties hibProps = new Properties();
hibProps.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("jbbconfigs.properties"));
Configuration cfg = new AnnotationConfiguration();
cfg.configure("/hibernate.cfg.xml").addProperties(hibProps);
//We create the SchemaUpdate thanks to the configs
SchemaUpdate schemaUpdate = new SchemaUpdate(cfg);
//The update is executed in script mode only
schemaUpdate.execute(true, false);
...
, hibernate.cfg.xml dosyası (ve .properties dosyası yok), ancak persistence.xml dosyası (JPA özelliği tarafından belirtilen şekilde META-INF dizininde otomatik olarak algılanır) içermiyor. Bu çok basit adaptasyon çalıştı
,
Configuration cfg = new AnnotationConfiguration();
cfg.configure();
ama bu istisna ile başarısız oldu.
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
Bunu yapan var mı? Teşekkürler.
Çal Framework günü, Ejb3Configuration üzerinde getHibernateConfiguration() kullanın ve ben bir "sağlanan hiçbir veri kaynağı" elde ederiz. Bir bağlantıyı nasıl sağlayabilirim (oyunda DB.datasource.getConnection())? –