开发者

JPA , How can I tell what will be saved back to the database

I have a JPA entity that has child开发者_StackOverflow社区 collections via OneToMany relationships and I have set cascade=CascadeType.ALL however when I save the parent entity it does not save any changes done to the child collection (i.e adds or removes) , I have no idea why this is.

It would be useful to know if there was a way to get any information from JPA EntityManager etc about what will be saved at the end of the transaction.

Not sure how to do this? Debugging this has become impossible.


One solution to see what is happening at a SQL level is to turn on debugging on hibernate. If you add a log4j.properties file to your /conf directory, you can manually control the hibernate log output. Here is a sample config file you can use. Uncomment the appropriate areas to turn up log levels:

log4j.logger.org.hibernate=info
### log just the SQL
log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=info

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜