Hibernate没有看到带有引号的表 [英] Hibernate doesn't see tables with quotes in name

查看:118
本文介绍了Hibernate没有看到带有引号的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在db(postgresql)中有一些表,名字是这样的Test。当我尝试从这个表中创建java类时,hibernate没有发生。我从名称类似于 test 的表中获得类。如何使hibernate能够查看带名称的表?

也许我写的问题不正确。但我不能创建java类,我想知道如何做与在qoutes名称的表反向ingenering。我不能从表名和列名中删除qoutes,他们有类型和完整名称。

解决方案

默认情况下,Hibernate假定数据库表名与类名相同,但您可以通过 @Table 注释覆盖此行为:

  @Entity 
@Table(name =\Test \)//将使用Test(包括引号)作为表名
public class Test {


I have some tables in db(postgresql) with names like this "Test".When i try create java classes from this tables with hibernate its not happening. I get classes from tables with names like this test. How to make hibernate can see tables with quotes in names?

UPDATE

Maybe i write question not correct. But i cant create java classes and i want to know how to do reverse ingenering with tables which have names in qoutes. I cant delete qoutes from table names and column names couse they have names like Type and Full.

解决方案

By default, Hibernate assumes the database table name is the same as the class name, but you can override this behaviour via the @Table annotation:

@Entity
@Table(name="\"Test\"") // Will use "Test" (including the quotes) as the table name
public class Test {

这篇关于Hibernate没有看到带有引号的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆