JAVA - JPA

HIBERNATE

hibernate.ddl-auto :

create : will delete and create new table every startup , so will make data lost

create-drop : same as create but will delete and create when session down and up

update : create when first time and update every startup keep date

validate : check and create/update tables every startp

none : do noting


JPA

GeneratedValue(strategy = GenerationType.XXXXXX)

the strategy of primary key

TABLE: need to use with @TableGenerator 

SEQUENCE: use Sequnce (like a temp table) ony Orcale , PSQL,DB2 support

IDENTITY:  control by table(database) ORacle not support

AUTO : Default ,control by springboot


在Hibernate中,提供了懒加载功能,当需要的时候才查询具体数据,但是在使用@OneToOne关系时, FetchType.LAZY看起来不会生效。

当你查询一个实体类A,这个实体类A持有另一个实体类B的引用,但是A中并没有记录B的主键,这种情况下,即使有懒加载注解,查询实体A的时候依然会执行两条SQL,分别查询实体类A和B对应的表A和表B。这是由于Hibernate的机制导致,并不是你的使用方式有问题或者存在其他bug。

————————————————

版权声明:本文为CSDN博主「_古井心」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u010234516/article/details/103011494




留言

此網誌的熱門文章

MAP - Sort with stream

JAVA - DSF Example