toplink-essentials

JPA Self Join using JoinTable

萝らか妹 提交于 2019-12-29 09:36:06
问题 I have 1 entity call Item in which I want to be able to link parent items to children. to use a join table to create a parent/child relationship. I haven't been able to get any good documentation on. So if anyone has any thoughts I'm all ears. Here is what I have... which works most of the time. public class Item implements java.io.Serializable { @Id private Long id; @ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinTable(name = "ITEMTOITEM", joinColumns = { @JoinColumn(name = "ITEMID"

JPA IndirectSet changes not reflected in Spring frontend

痞子三分冷 提交于 2019-12-11 03:56:14
问题 EDIT: Solved, but I don't know what was different now. If anyone can explain what happened differently, I'd appreciate it. The way it's working now is by merging only the Parent, not the Child at all, like so: Parent parent = child.getParent(); parent.getChildren().add(child); getJpaTemplate().merge(parent); Now, it seems to be working, but I don't quite get why this would work while my previous attempt didn't. Original attempt/question: I'm having an issue with Spring JPA and IndirectSets. I

How to reestablish a JDBC connection after a timeout?

蹲街弑〆低调 提交于 2019-12-10 11:16:11
问题 I have a long-running method which executes a large number of native SQL queries through the EntityManager (TopLink Essentials). Each query takes only milliseconds to run, but there are many thousands of them. This happens within a single EJB transaction. After 15 minutes, the database closes the connection which results in following error: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b02-p04 (04/12/2010))): oracle.toplink.essentials.exceptions.DatabaseException Internal

How to reestablish a JDBC connection after a timeout?

别说谁变了你拦得住时间么 提交于 2019-12-06 06:16:59
I have a long-running method which executes a large number of native SQL queries through the EntityManager (TopLink Essentials). Each query takes only milliseconds to run, but there are many thousands of them. This happens within a single EJB transaction. After 15 minutes, the database closes the connection which results in following error: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b02-p04 (04/12/2010))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Closed Connection Error Code: 17008 Call: select ... Query:

Are entities cached in jpa by default?

安稳与你 提交于 2019-12-03 15:29:50
问题 I add entity to my database and it works fine. But when i retrieve the List, i get the old entity, the new entities i add are not shown until i undeploy the application and redeploy it again. This means are my entities cached by default? But, I haven't made any settings for caching entities in my persistence.xml or any such file. I have even tried calling flush(), refresh() and merge(). But still it shows the old entities only. Am i missing something? Please help me. 回答1: Welcome to JPA. If

Are entities cached in jpa by default?

萝らか妹 提交于 2019-12-03 05:04:48
I add entity to my database and it works fine. But when i retrieve the List, i get the old entity, the new entities i add are not shown until i undeploy the application and redeploy it again. This means are my entities cached by default? But, I haven't made any settings for caching entities in my persistence.xml or any such file. I have even tried calling flush(), refresh() and merge(). But still it shows the old entities only. Am i missing something? Please help me. Welcome to JPA. If you use it, it means you will have huge problems if you update the database outside of JPA unless you know

JPA: Does EntityManager.find() always return the same object reference for the same key?

余生长醉 提交于 2019-12-01 23:20:16
问题 I've got an integration test of a DAO in which I use a shared EntityManager (via Spring, using SharedEntityManagerCreator). The test class is marked as @Transactional, as is the DAO method under test. In both the test class and the DAO I'm retreiving a User entity as follows: User user = em.find(User.class, "test"); In the setup of my test I've modified the user object, but I wasn't seeing the modification in the DAO when the test came to run. It turned out that the two references did not

JPA: Does EntityManager.find() always return the same object reference for the same key?

一曲冷凌霜 提交于 2019-12-01 22:27:31
I've got an integration test of a DAO in which I use a shared EntityManager (via Spring, using SharedEntityManagerCreator). The test class is marked as @Transactional, as is the DAO method under test. In both the test class and the DAO I'm retreiving a User entity as follows: User user = em.find(User.class, "test"); In the setup of my test I've modified the user object, but I wasn't seeing the modification in the DAO when the test came to run. It turned out that the two references did not refer to the same object; I proved this in my test class using: System.out.println("User objects equal = "

Why JPA persist() does not generated auto-increment primary ID?

帅比萌擦擦* 提交于 2019-11-30 04:18:49
问题 I'm using JPA toplink-essential and SQL Server 2008 My goal is to get auto-increment primary key value of the data that is going to be inserted into the table. I know in JDBC, there is getInsertedId() like method that give you the id of auto-increment primary id (but that's after the insert statement executed though) In JPA, I found out @GenratedValue annotation can do the trick. @Entity @Table(name = "tableOne") public class TableOne implements Serializable { private static final long

JPA Self Join using JoinTable

主宰稳场 提交于 2019-11-29 17:35:36
I have 1 entity call Item in which I want to be able to link parent items to children. to use a join table to create a parent/child relationship. I haven't been able to get any good documentation on. So if anyone has any thoughts I'm all ears. Here is what I have... which works most of the time. public class Item implements java.io.Serializable { @Id private Long id; @ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinTable(name = "ITEMTOITEM", joinColumns = { @JoinColumn(name = "ITEMID") }, inverseJoinColumns = { @JoinColumn(name = "PARENTITEMID") } ) private Item parent; @OneToMany