English 中文(简体)
JPA+Hibernate的载体
原标题:Cascading in JPA+ Hibernate

我的实体如下:



public class EntityA {

   //...
   @OneToMany(mappedBy="entityA")
   private Set entitieBs;

}

public class EntityB {

   //...
   @ManyToOne(cascade=CascadeType.PERSIST)
   private EntityA entityA;

}

with accessors methods(getters and setters).

我打算每次在数据库中节省一个新的EntityB物体(有 EntityA作为“母”设定的物体)时,如果我打电话EntityA.getEntityBs()在新的EntityB的母子上添加这一编号。 但是,如果我像我的榜样那样做,那就没有工作了。

是否有任何人知道我在哪里错了?

感谢!


这里是我如何坚持该实体的 j。


//...some code
EntityB eb = new EntityB();
eb.setEntityA(entityA);
entityManager.persist(entityB);

我愿表明,我没有增加<斯特隆>entityB至>的一组实体。 Bs.

最佳回答

每隔两天就提出这一问题。

日本宇宙航行局没有保持你物体图表的一致性。 它负责维持双向协会的双方。 如果你进行交易、结束会议并重载这些实体,那么你将尽一切可能,因为你们已经启动了协会自己的一方。 但是,如果你篡改协会的一面,人民军会为你们赢得了另一边的修改。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...