hibernate

JPA - @PreRemove method behaviour

戏子无情 提交于 2021-02-06 20:00:46
问题 I have 2 entities with many-to-many relationship. The Movie Entity is the owner of this relation, so when I want to delete an Actor Entity I use a method annotated @PreRemove to delete any occurrences of Actor ID in Movie cast to avoid "Foreign key violation exception". Movie class @Entity public class Movie extends AbstractBusinessObject{ @ManyToMany private Map<String, Actor> cast; // setters and getters public void removeCastMember(Actor actor){ for (Entry<String, Actor> e : cast.entrySet(

Spring Data JPA with ssh tunnel to a remote MySQL server

有些话、适合烂在心里 提交于 2021-02-06 14:24:55
问题 I'm using Spring Data JPA with Hibernate as persistence provider in conjunction with a remote MySQL5 Server for a job that periodically replicates a subset of internal data. The job (i.e. a quartz-scheduled java application) runs once per dai and needs approx. 30seconds to complete the synchronization). For safety reasons we don't want to open the remote server for direct connections from outside (i.e. other than localhost). I've seen examples with Jsch to programmatically set up an ssh

Spring Data JPA with ssh tunnel to a remote MySQL server

╄→гoц情女王★ 提交于 2021-02-06 14:05:21
问题 I'm using Spring Data JPA with Hibernate as persistence provider in conjunction with a remote MySQL5 Server for a job that periodically replicates a subset of internal data. The job (i.e. a quartz-scheduled java application) runs once per dai and needs approx. 30seconds to complete the synchronization). For safety reasons we don't want to open the remote server for direct connections from outside (i.e. other than localhost). I've seen examples with Jsch to programmatically set up an ssh

Spring Data JPA with ssh tunnel to a remote MySQL server

独自空忆成欢 提交于 2021-02-06 14:04:53
问题 I'm using Spring Data JPA with Hibernate as persistence provider in conjunction with a remote MySQL5 Server for a job that periodically replicates a subset of internal data. The job (i.e. a quartz-scheduled java application) runs once per dai and needs approx. 30seconds to complete the synchronization). For safety reasons we don't want to open the remote server for direct connections from outside (i.e. other than localhost). I've seen examples with Jsch to programmatically set up an ssh

mysql: keep auto-increment counter after server restart - inconsistent envers audit tables

拟墨画扇 提交于 2021-02-06 14:01:55
问题 I'm using InnoDb schema on mysql 5.5 . mysql 5.5 guide states: InnoDB uses the in-memory auto-increment counter as long as the server runs. When the server is stopped and restarted, InnoDB reinitializes the counter for each table for the first INSERT to the table, as described earlier. This is a big problem for me. I'm using envers to keep entities audits. I get as many errors as many "last rows" I delete. Suppose I'm starting insert data into an empty table. Suppose to insert 10 rows. Then

mysql: keep auto-increment counter after server restart - inconsistent envers audit tables

China☆狼群 提交于 2021-02-06 14:01:35
问题 I'm using InnoDb schema on mysql 5.5 . mysql 5.5 guide states: InnoDB uses the in-memory auto-increment counter as long as the server runs. When the server is stopped and restarted, InnoDB reinitializes the counter for each table for the first INSERT to the table, as described earlier. This is a big problem for me. I'm using envers to keep entities audits. I get as many errors as many "last rows" I delete. Suppose I'm starting insert data into an empty table. Suppose to insert 10 rows. Then

mysql: keep auto-increment counter after server restart - inconsistent envers audit tables

痞子三分冷 提交于 2021-02-06 14:00:39
问题 I'm using InnoDb schema on mysql 5.5 . mysql 5.5 guide states: InnoDB uses the in-memory auto-increment counter as long as the server runs. When the server is stopped and restarted, InnoDB reinitializes the counter for each table for the first INSERT to the table, as described earlier. This is a big problem for me. I'm using envers to keep entities audits. I get as many errors as many "last rows" I delete. Suppose I'm starting insert data into an empty table. Suppose to insert 10 rows. Then

Connections checking in c3p0 pool

我的梦境 提交于 2021-02-06 12:47:07
问题 I'm developing with Java SE application using Hibernate 4 and c3p0 for communication with MariaDB database. It's long running application, waiting for signals from outside, so sometimes database closes my connections after 8 hours of inactivity. I tried to configure c3p0 connections validating but it's not working. Could you help me? Error log (thrown during named query execution): 2014-10-27 08:10:19.062 ERROR [trans] com.example.runnable.T1 - Exception thrown during event processing,

Connections checking in c3p0 pool

我只是一个虾纸丫 提交于 2021-02-06 12:46:26
问题 I'm developing with Java SE application using Hibernate 4 and c3p0 for communication with MariaDB database. It's long running application, waiting for signals from outside, so sometimes database closes my connections after 8 hours of inactivity. I tried to configure c3p0 connections validating but it's not working. Could you help me? Error log (thrown during named query execution): 2014-10-27 08:10:19.062 ERROR [trans] com.example.runnable.T1 - Exception thrown during event processing,

Exclude a specific table from being created by hibernate?

﹥>﹥吖頭↗ 提交于 2021-02-06 09:51:30
问题 I have an @Entity which is mapped to a view, here is how it looks import org.hibernate.annotations.Immutable; import javax.persistence.*; @Table(name = "user_earning") @Entity @Immutable public class UserFlightEarning { @Id public Long userId; public Long flightId; @Column(name = "flight_seq") public Long flightSequence; } This works fine, I can retrieve records from the view using the dao. However I noticed in the logs that Hibernate is actually trying to create the table but failing because