Hibernate 在JBoss中指定Postgresql数据源默认模式
我在JBoss上设置了一个数据源,用于连接eap 6.2和Postgresql 9.3.2。 我使用的是Hibernate 在JBoss中指定Postgresql数据源默认模式,hibernate,postgresql,datasource,jboss6.x,Hibernate,Postgresql,Datasource,Jboss6.x,我在JBoss上设置了一个数据源,用于连接eap 6.2和Postgresql 9.3.2。 我使用的是postgresql-9.3-1100.jdbc4.jar驱动程序。 当使用JBoss管理控制台中的测试连接按钮时,它成功连接 尝试通过java连接(查询/持久化)实体时,会出现以下错误: org.postgresql.util.PSQLException: ERROR: relation "student" does not exist 我在persistence.xml中添加了以下行以包
postgresql-9.3-1100.jdbc4.jar
驱动程序。
当使用JBoss管理控制台中的测试连接按钮时,它成功连接
尝试通过java连接(查询/持久化)实体时,会出现以下错误:
org.postgresql.util.PSQLException: ERROR: relation "student" does not exist
我在persistence.xml中添加了以下行以包括模式
<property name="hibernate.default_schema" value="archu"/>
我已经通过Netbeans查询了数据库,它的工作原理是修改“archu.student”为archu.student
在数据库中,表Student使用大写字母s拼写,而JBoss datasource使用小写字母。JBoss数据源还附加了模式,但“”位于archu和student附近,这不想工作
是否有更好的方法在数据源中指定模式并告诉数据源不要将所有内容都设置为小写 我要求hibernate删除并为我创建表 Persistence.xml条目:
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
启用以下选项后,我可以看到区别
即使实体名为student“uppercase S”,也会创建名称为“student”且全部小写的表
它通过hibernate将新创建的表与persistence.xml中的模式项结合使用
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>