Questions Tagged With hibernatehttps://answers.axonivy.com/tags/hibernate/?type=rssquestions tagged <span class="tag">hibernate</span>enFri, 21 Feb 2020 04:08:26 -0500The hibernate jpamodelgen cannot generate entities extended from a dependency projecthttps://answers.axonivy.com/questions/4407/the-hibernate-jpamodelgen-cannot-generate-entities-extended-from-a-dependency-project<p>I have 2 project A and B. Project A dependency project B. Project B have a "ToggleableEntity" class and Project A have a "OrganizationalUnit" class</p> <p>"OrganizationalUnit" class extend "ToggleableEntity" class. When I build with maven and using hibernate jpamodelgen to generate "OrganizationalUnit_" class then ToggleableEntity missed in "OrganizationalUnit_" class</p> <p>The pom.xml file <img alt="alt text" src="https://answers.axonivy.com/upfiles/demo_3.JPG"></p> <p>The result: <img alt="alt text" src="https://answers.axonivy.com/upfiles/demo_1.png"></p> <p>The expected <img alt="alt text" src="https://answers.axonivy.com/upfiles/demo_4.JPG"></p>anhleFri, 21 Feb 2020 04:08:26 -0500https://answers.axonivy.com/questions/4407/the-hibernate-jpamodelgen-cannot-generate-entities-extended-from-a-dependency-projectmavenhibernatenvarchar(max)https://answers.axonivy.com/questions/1988/nvarchar-max<p>Hi All,</p> <p>What is the recommendation for having column like nvarchar(max) ? what should I put in the Length value in the designer when creating Entities nvarchar(max) ? 2147483647 maybe ?</p> <p>Best Regards, Yordan</p>Stelt0Wed, 24 Aug 2016 16:31:53 -0400https://answers.axonivy.com/questions/1988/nvarchar-maxhibernateentity-managerpersistenceEnums in Entity Classeshttps://answers.axonivy.com/questions/1899/enums-in-entity-classes<p>Hi All,</p> <p>What is the best practice in ivy to manage Enums in persistence classes ?</p> <p>this example looks fine to me <a href="http://www.codejava.net/frameworks/hibernate/hibernate-enum-type-mapping-example">http://www.codejava.net/frameworks/hibernate/hibernate-enum-type-mapping-example</a> </p> <p>but how do I implemented in in ivy ? how to add @Enumerated to a field ?</p> <p>Best Regards, Yordan Yunchov</p>Stelt0Mon, 18 Jul 2016 08:58:08 -0400https://answers.axonivy.com/questions/1899/enums-in-entity-classesdataclasshibernateenumHibernate show_sqlhttps://answers.axonivy.com/questions/1585/hibernate-show_sql<p>Hello Ivy-Team,</p> <p>how can I configurate the hibernate.show_sql property? I tried to configurate it in the persistence configuration editor but nothing happened. Is there something else I have to do?</p> <p>Thanks for answers<img alt="alt text" src="http://answers.axonivy.com/upfiles/Unbenannt_FWwrALz.png"></p>Florian HeinrichFri, 04 Dec 2015 15:42:51 -0500https://answers.axonivy.com/questions/1585/hibernate-show_sqlhibernateloggingAdding additional Libraries to Hibernate, e.g. Envershttps://answers.axonivy.com/questions/1138/adding-additional-libraries-to-hibernate-e-g-envers<p>Hello Ivy-Developers!</p> <p>Envers is a powerfull Library, that comes along with the Hibernate-Package and allows auto-Auditing for entities. (History-Tables etc.)</p> <p>Update:</p> <p>To insert the library I did as following: Added hibernate-envers-4.2.13.Final.jar to ivy-Hibernate-jar:</p> <p>designer\plugins\ch.ivyteam.hibernate_5.1.0.201409121008.jar\lib\mvn\</p> <p>made some changes in the ivy-Hibernate-jar: ',lib/mvn/hibernate-envers-4.2.13.Final.jar' added to MANIFEST.MF</p> <p>in pom.xml I inserted a new dependency for hibernate-envers (see pom.xml)</p> <p>When inserting this library this unusual way, there are no more errors accessing the persistence.</p> <p>Adding @Audited to the Entity gives no error, but no auditing happens on merge.(Wich would usualy be the case)</p> <p>Merging through the EntityManager (from createEntityManager()) does not work (Nothing happens, no error)</p> <p>Trying to access the AuditReader will fail on a ClassNotFoundException: org.hibernate.envers.AuditReaderFactory</p> <pre><code>// switching contextClassLoader to ivy.request.getProject().getProjectClassLoader() EntityManager em = entityManager.createEntityManager(); AuditReaderFactory.get(em); </code></pre> <p>As I understand this has been successfully implemented in the csc project.</p> <p>So the questions are: How can I integrate this library into Ivy? If not possible, is there a way to detach Hibernate more from Ivy?</p> <p>Installation as described in: <a href="http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch15.html">Guide from Hibernate</a> </p> <p>Thanks in advance!</p> <p>Greetings Alexis</p>AlexisTue, 27 Jan 2015 17:05:26 -0500https://answers.axonivy.com/questions/1138/adding-additional-libraries-to-hibernate-e-g-envershibernatepersistenceHow to use JPA entity manager instead of Ivy Entity Manager?https://answers.axonivy.com/questions/1102/how-to-use-jpa-entity-manager-instead-of-ivy-entity-manager<p>Hi everyone,</p> <p>Currently, I need to set up and use the JPA entity manager not Ivy Entity Manager because our team want it to work with JUnit. (Ivy Entity Manager doesn't work with JUnit because of Ivy environment).</p> <p>Is that possible to do so? I have tried edit the persistence.xml and try to create an entity manager but I've got the exception:</p> <pre><code>javax.persistence.PersistenceException: [PersistenceUnit: xrfl_unit] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at ch.soreco.standard.xrfl.service.TransactionManager.execute(TransactionManager.java:38) at ch.soreco.standard.xrfl.service.ValuationService.findAll(ValuationService.java:26) at ch.soreco.standard.xrfl.unittest.service.ValuationServiceTest.findAll(ValuationServiceTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.hibernate.service.jndi.JndiException: Error parsing JNDI name [XRFL] at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:92) at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:63) at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783) at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ... 31 more Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getNameParser(Unknown Source) at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:86) ... 45 more </code></pre> <p>If you have any idea or suggestion, please share with me.</p> <p>Thank You.</p>Tran Cuong TrucMon, 22 Dec 2014 03:47:09 -0500https://answers.axonivy.com/questions/1102/how-to-use-jpa-entity-manager-instead-of-ivy-entity-managerjpaunit-testhibernate