简体   繁体   English

休眠:使用hql删除子条目

[英]Hibernate : Delete child entry using hql

Good Day to all, 祝大家有美好的一天

I have a trouble in hibernate and i am a fresher in hibernate, i wish to delete a child entry using hql , if you have a solution please help me and now i am using pojo classes for creating the entities not xml mapping. 我在hibernate中遇到了麻烦,我在hibernate中比较新鲜,我希望使用hql删除子项,如果您有解决方案,请帮助我,现在我正在使用pojo类来创建实体而不是xml映射。

how can give a default value for a table attribute while creating new entity using class mapping (in pojo) not xml mapping 在使用类映射(在pojo中)而不是xml映射创建新实体时,如何为表属性提供默认值

Thanks in advance 提前致谢

You normally don't use HQL to delete entities, but use session.delete(entity) . 通常,您不使用HQL删除实体,而是使用session.delete(entity) If you have a cascade remove set on the association (or a cascade all), the the child entity will be deleted along with the parent entity. 如果您在关联上设置了级联删除(或全部级联),则子实体将与父实体一起删除。 Read the hibernate reference manual to learn more and see examples. 阅读休眠参考手册以了解更多信息并查看示例。

To specify a default value for a column when generating the schema using Hibernate, you might use the columnDefinition attribute of the Column annotation. 要在使用Hibernate生成架构时为列指定默认值,可以使用Column批注的columnDefinition属性。 I usually prefer to generate the database schema by hand , though. 不过,我通常更喜欢手动生成数据库模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM