Questions Tagged With persistencehttps://answers.axonivy.com/tags/persistence/?type=rss&user=Alexisquestions tagged <span class="tag">persistence</span>enTue, 27 Jan 2015 17:05:26 -0500Adding 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-envershibernatepersistencePersistence Api - Catching NoResultExceptionhttps://answers.axonivy.com/questions/1049/persistence-api-catching-noresultexception<p>Hello</p> <p>How do I catch a NoResultException after calling the getSingleResult() on a custom query, wich often doesn't return any result. Catching the NoResultException still logs an error (<strong>NoResultException: No entity found for query</strong>) and after that the Info is printed out. Happens both in the designer and on the server.</p> <pre><code>catch (NoResultException e) { Ivy.log().info("No Result has been found for Debitor '"+number+"'."); } </code></pre> <p>haven't tested yet with other Exceptions like NonUniqueResultException.</p> <p>Thank you in advance</p>AlexisTue, 25 Nov 2014 16:35:41 -0500https://answers.axonivy.com/questions/1049/persistence-api-catching-noresultexceptionpersistenceComposite Primary Key in Persistencehttps://answers.axonivy.com/questions/1039/composite-primary-key-in-persistence<p>Hi</p> <p>Is there any way to have multiple ID's in one Entity? Corresponding JPA it should be possible. But trying in the designer I get: Exaclty one 'Id' field per Entity Class must be used. Although it is not named 'Id'. Would be saving a lot of work, when this is enabled.</p> <p>Best Regards</p> <p>Alexis</p>AlexisTue, 18 Nov 2014 15:00:16 -0500https://answers.axonivy.com/questions/1039/composite-primary-key-in-persistencepersistenceNot visible Interface on persistence queryhttps://answers.axonivy.com/questions/945/not-visible-interface-on-persistence-query<p>Calling a query on a table with BLOBs (Files in Tables) using the jTDS-Driver I get a class-loader error:</p> <p><code>java.lang.IllegalArgumentException: interface org.hibernate.engine.jdbc.WrappedBlob is not visible from class loader</code></p> <p>My Solution was to switch to an other classloader:</p> <pre><code> public synchronized void method() { Thread thread = Thread.currentThread(); ClassLoader tempLoader = thread.getContextClassLoader(); thread.setContextClassLoader(null); entityManager.createNativeQuery("select * from TSRPTBLB where TSBID = 1 ") .getSingleResult(); thread.setContextClassLoader(tempLoader); } </code></pre> <p>Will there be any other, cleaner way than switsching the classloader?</p> <p>Thank you in advance</p>AlexisTue, 09 Sep 2014 14:41:36 -0400https://answers.axonivy.com/questions/945/not-visible-interface-on-persistence-queryjavaivypersistence