我在和Jhipster一起工作。我不能懒洋洋地招揽顾客。 我已经做了一个JDL,就像这样... PROPERTY
id
...
CUSTOMER
id
...
CUSTOMER_PROPERTY
id
customer_id
property_id
value
relationship OneToMany {
Customer to CustomerProperty
}
relationship ManyToOne {
CustomerProperty to Property
} 我的域名 C
我有两个类似下面的实体:
@Entity
@DynamicUpdate
public class EntityOne {
@Id
public long id;
public String name;
public String displayName;
@JsonManagedReference
@OneToMany(mappedBy = "id", cascade = CascadeType.ALL)
@OrderBy(value = "name")
public List<E
在SPRING ROO中,我有带有OneToMany关系的Team和Person表。虽然创建团队字段正确地作为名字出现,但当go for list all team时,它将显示person表的所有值,即名字、姓氏等。
我的代码是这样的:
// Person with Team mapping
@OneToMany(cascade = CascadeType.ALL,mappedBy = "Fname")
private Set<Team> teams = new HashSet<Team>();
@ManyToOne
private Person Fna
目前,我的OneToMany/ManyToOne-映射遇到了问题。映射如下:
public class A implements Serializable {
@EmbeddedId
private AId id;
// Other stuff...
}
@Embeddable
public class AId implements Serializable {
@ManyToOne
@JoinColumn(name = "B_ID", nullable = false)
private B b;
// Other
我有两个域类,PO类和Product,在PO类中有一个列表。因此,产品是ManyToOne到PO,PO是OneToMany到Product。
public class PO {
....
@OneToMany(mappedBy = "po", cascade= CascadeType.ALL, orphanRemoval=true)
private List<Product> products = new ArrayList<>();
.....
}
public class Product {
....
在我的申请中我有一个表演问题。
我有三个实体,其关系如下:
one Order => many OrderLines => Many Cards
从数据库加载实体需要花费太多的时间,orderLines加载的是急切的加载,而卡片的加载则是延迟加载。延迟加载是必要的,以使应用程序流畅。
我需要为一个案例配置急切的加载,我需要帮助来完成它。
我正在使用jhsipster堆栈:使用JPA的spring
我试着写Hql查询
@Query(value = "from Order as order "
+ "inner join order.orderL
我正在使用Hibernate JPA1.0。
我有以下类型的模型,我认为manyToOne和oneToOne关系是“急切地”获取的,oneToMany是“惰性地”获取的。
我想获取实体A及其所有关联,在哪里a.id=?
A oneToMany B
B oneToOne C
C oneToMany D
- B oneToOne E
- E oneToMany D
- B oneToOne F
- F oneToMany D
是否可以在一个查询中加载该实体?或者在一个子集的查询中,记住"n+1选择问题“!
到目
我正在开发一个Spring-MVC应用程序,试图为两个实体之间已经存在的一对多映射添加多对多映射。我们在项目中拥有的两个实体是GroupSection和GroupNotes。
对于项目中的一项任务,我必须在GroupSection和GroupNotes之间引入多对多映射,但我得到了一个延迟初始化异常。
错误:
org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: failed to lazily initialize a collection of role: c
我正在尝试将Javer与Spring数据REST项目集成起来。目前,我的域中有以下实体。
Student.class
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String firstName;
private String lastName;
private Long dob;
@On
我在Spring Roo中定义了两个实体之间的双向多对一关系。
@RooEntity
public class Car {
@OneToMany(mappedBy="car")
private Set<Wheel> wheels = new HashSet<Wheel>();
}
@RooEntity
public class Wheel {
@ManyToOne
@JoinColumn (name = "wheels_fk")
private Car car;
}
持久化所有者端(控制盘)上的更改。
但是,
在我的项目中,我使用Spring ,并为数据获取类扩展JpaRepository接口。
OrganizationMaster类:
@Entity
@Table(name="organization_master")
public class OrganizationMaster {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="organization_id")
private int organizationId;
当我尝试懒惰地读取子实体的列表时,我(间歇性地)得到了这个错误。 failed to lazily initialize a collection of role: G.h, could not initialize proxy - no Session 关于这个错误,我已经看过了SO上的帖子列表。我所能找到的就是做急切的获取或者使用hibernate.enable_lazy_load_no_trans属性。我不想这样做,因为它们是反模式。 而且我在类级别上有@Tranastional(readOnly=true),在那里我从数据库读取数据,所以我希望hibernate会话在事务完成之前一直
我正在开发一个使用Spring Boot,Spring Data JPA和Spring Data Rest技术的web项目。我能够成功地设置一切,并能够获得一个简单的POJO的JSON。我自定义了两个类来实现OneToMany和ManyToOne的关系,如下所示:
@Entity
@Table(name="t_profile")
public class Profile {
@Id
@column(name="profile_id")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
我有以下两个具有双向关系的实体@OneToMany和@ManyToOne。如下所示,当我使用join查询查询子表时,hibernate会自动为每个MinuteData (子表)查询StandardDimension (父)表,以加载@ManyToOne关系,即使它被标记为延迟加载。这会导致数据库性能问题。你能帮我解决这个问题吗?对于每个MinuteData,它不会加载标准维度记录?我使用的是JPA2.0和hibernate-core-4.1.1。任何帮助都将不胜感激。如何阻止hibernate加载StandardDimension对象?
@Query("SELECT md FROM S