java - Hibernate add custom prefix to the catalogs -


After

I am using Hibernate 4.3.6 and I need to add custom prefix to my list on the basis of the environment is. I used this code in 4.2.3

  Personal Static SessionFactory buildSessionFactory () {configuration config = new configuration (try) {version; Config.configure ("db.cfg.xml"); Config.buildMappings (); ServiceRegistry Registry = New StandardServiceRegistryBuilder () .applySettings (config.getProperties ()) .build (); If (prefix! = Null & amp; prefix; isitit ()) {eiter & lt; Table & gt; Iterator = config.getTableMappings (); While (iterator.hasNext ()) {table table = (table) iterator.next (); Table.setCatalog (prefix + table tag) ()); }} // Back New Annotation Configuration () BuildSessionFactory (Registry); Session factory factory = config.buildSessionFactory (Registry); Return factory; } Catch (pre-throttle) {// Make sure you log exception, because this system. Er Can swallow print (ex); New ExceptionInInitializerError (ex) Throw; }}  

but now these errors are out

  config.buildSessionFactory (Registry); On sun.reflect.NativeMethodAccessorImpl.invoke db.DatabaseEngine.buildSessionFactory (DatabaseEngine.java:110) sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method java.lang.ExceptionInInitializerError (NativeMethodAccessorImpl.java:57) on) on sun.reflect . DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:606) organization on org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java:47) . On junit.internal.runners.model.ReflectiveCallable.run org.junit.runners.model.FrameworkMethod.invokeExplosively (ReflectiveCallable.java:12) (FrameworkMethod.java:44) on org.junit.internal.runners.statements.InvokeMethod. Rate (invokeMethod.java:17) on org.junit.runners.BlockJUnit4ClassRunner.RunChild (BlockJUnit4ClassRunner.java:70) on parent.unit.runners.ParentRunner.runLeaf (ParentRunner.javaAMS71) on Org.junit.runners. On Org.junit.runners.BlockJUnit4ClassRunner .runChild (BlockJUnit4ClassRunner.java:50) at $ 3.run org.junit.runners.ParentRunner $ 1.schedule at Ner org.junit on org.junit.runners.ParentRun (ParentRunner.java : 238) (parentRunner.java:63) org.junit.runners.ParentRunner.runChildren (ParentRunner.java, 36) at .runners.ParentRunner.access $ 000 org.junit.runners.ParentRunner at $ 2.evaluate (ParentRunner. java: 53) org.eclipse.jdt org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run on (ParentRunner.java:229) org.junit.runners.ParentRunner.run (ParentRunner.java:309). At internal.junit.runner.TestExecution.run (TestExecution.java:38) (JUnit4TestReference.java:50) at org.eclipse. jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:459) org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:675) on org.eclipse.jdt.internal. java.lang.NullPointerException at org.hibernate: due to junit.runner.RemoteTestRunner.run on org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:382) (RemoteTestRunner.java:192) . cfg.Configuration.secondPassComp Ile (Configuration.java:1456) org.hibernate.cfg.Configuration.buildSessionFactory (Configuration.java:1844)   

Is there such a thing for ImprovedNamingStrategy but for catalogs like this?

orm.xml

After you create, you can load it using the following code: < / P>

  configuration configuration = new configuration (); Config.configure ("db.cfg.xml"); Config.addResource ("orm.xml"); // load these files in any order; config.buildMappings ();  

See Vlad's answer to create an orm.xml file.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -