无法使用名为“user”的表格在postgresql休眠 [英] Unable to use table named "user" in postgresql hibernate
本文介绍了无法使用名为“user”的表格在postgresql休眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我试图用JPA / hibernate持久化名为user的实体时,它不起作用。该表未创建,这是因为用户是postgresql中的保留字。除此之外,还有什么其他方法可以使这个工作成为可能?
解决方案
要引用一个标识符,请使用back ticks:
@Table(name =`users`)
从Hibernate的测试套件中看到这个例子:
Hibernate会自动检测并转换为您正在使用的数据库的适当报价。
When I try to persist an entity called "user" with JPA/hibernate it does not work. The table is not created and it is because user is a reserved word in postgresql. Is there any way other than naming the table something else to make this work?
解决方案
To quote an identifier, use back ticks:
@Table(name="`users`")
See this example from Hibernate's test suite:
Hibernate will automatically detect it and convert to the appropriate quote for the database you are using.
这篇关于无法使用名为“user”的表格在postgresql休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文