jpa

JPA functionality in a deployed WAR on Tomcat

余生长醉 提交于 2021-02-04 21:43:06
问题 I'm working on a project which aims to allow a user to add some film details to a database and displays the list of existing films. I have created a Dynamic Web Project in Eclipse using JPA to communicate with a remote database. All of this works fine when I run the project in the Eclipse IDE but when I export it to a WAR and deploy it on a Tomcat server the JPA functionality no longer works. The following error is thrown: javax.servlet.ServletException: Servlet execution threw an exception

Is it possible to turn off hibernate version increment for particular update?

断了今生、忘了曾经 提交于 2021-02-04 17:15:46
问题 Is it possible update entity in database without modifying version of entity using hibernate? Using my web application users can create or update entities. And where is another asynchronous process which “processes” these entities after any user operation. If user opens entity for update before entity is “processed”, but tries to save it after it is “processed”, user will get “OptimisticLockException” and all his entered data will be lost. But I would like to overwrite data updated in

@PreUpdate doesn't save parent object when it's updated

前提是你 提交于 2021-02-04 14:10:19
问题 I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications( childrenLastModifiedDate ). To maintain that, I added method: @PrePersist @PreUpdate @PreRemove private void handle() { parent.setChildrenLastModifiedDate(now()); } Here is the problem. It's not always invoke when the child is saved. Locally(mac os), it works as expected, all three types of changes are tracked and saved to

@PreUpdate doesn't save parent object when it's updated

我们两清 提交于 2021-02-04 14:08:50
问题 I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications( childrenLastModifiedDate ). To maintain that, I added method: @PrePersist @PreUpdate @PreRemove private void handle() { parent.setChildrenLastModifiedDate(now()); } Here is the problem. It's not always invoke when the child is saved. Locally(mac os), it works as expected, all three types of changes are tracked and saved to

@PreUpdate doesn't save parent object when it's updated

风格不统一 提交于 2021-02-04 14:08:47
问题 I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications( childrenLastModifiedDate ). To maintain that, I added method: @PrePersist @PreUpdate @PreRemove private void handle() { parent.setChildrenLastModifiedDate(now()); } Here is the problem. It's not always invoke when the child is saved. Locally(mac os), it works as expected, all three types of changes are tracked and saved to

@PreUpdate doesn't save parent object when it's updated

[亡魂溺海] 提交于 2021-02-04 14:07:57
问题 I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications( childrenLastModifiedDate ). To maintain that, I added method: @PrePersist @PreUpdate @PreRemove private void handle() { parent.setChildrenLastModifiedDate(now()); } Here is the problem. It's not always invoke when the child is saved. Locally(mac os), it works as expected, all three types of changes are tracked and saved to

javax.persistence.TransactionRequiredException: no transaction is in progress, @Transactional(propagation=Propagation.REQUIRED) not working

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-04 05:04:10
问题 Whenever I try to entityManager.flush() I get the error mentioned on title. That is interesting that all my models have been created properly on MySql during application start up. I have read several questions with similar exception and basically all of them point to use/change @Transaction somehow. Any suggestion or even a scratch idea about what to check will be highly appreciated. I don't think it is really relevant but let me inform btw: I am using WebSphere Liberty Profile + MySql. where

javax.persistence.TransactionRequiredException: no transaction is in progress, @Transactional(propagation=Propagation.REQUIRED) not working

爱⌒轻易说出口 提交于 2021-02-04 05:03:23
问题 Whenever I try to entityManager.flush() I get the error mentioned on title. That is interesting that all my models have been created properly on MySql during application start up. I have read several questions with similar exception and basically all of them point to use/change @Transaction somehow. Any suggestion or even a scratch idea about what to check will be highly appreciated. I don't think it is really relevant but let me inform btw: I am using WebSphere Liberty Profile + MySql. where

How to represent Oracle Interval in Java

…衆ロ難τιáo~ 提交于 2021-02-02 09:15:27
问题 I'm using Java 7 with hibernate 4. Want to use oracle Interval data type (http://psoug.org/definition/INTERVAL.htm) to represent a interval of a certain number of days. Wondering what Java Type to use to map this Oracle Interval Object. I would like to use standard Java objects and not any oracle.sql.* objects as mentioned in this document http://docs.oracle.com/cd/B28359_01/java.111/b31224/datacc.htm. Here's the table I'm playing with: CREATE TABLE "MyTest" ( "ID" NUMBER(14,0) NOT NULL

Will hibernate increment version if I add/remove/update element of dependable collection?

蹲街弑〆低调 提交于 2021-01-29 22:19:20
问题 I am learning hibernate optimistic lock mechanism and I haven't found answer on my question in user guide Let's say we have entity like this: @Entity class Employee{ @Version Long versionField; List<Employee> subordinates; ... } And somewhere we have following code: Employee sub = .... Emplyee emp = readEmploye(); emp.getSubordinates().add(sub); Can I control of version incrementation at this case ? 回答1: By default no. Since you're not changing the entity, but rather other entities that are