hibernate找不到模式
拥有wildfly 8.2.0 有一个postgres数据库和一个名为“authorization_central”的模式 实体模式为: persistence.xml是 发送给我错误: 错误[org.hibernate.engine.jdbc.spi.SqlExceptionHelper]未找到默认任务7架构授权\u中心;SQL语句: 在authorization_central.tblusers中插入密码、用户名、id值?、?、?[90079-173] 然后创建了一个名为rastinuser的用户 已创建名为rastindb的数据库 使用此用户和数据库登录。psql-d rastindb-U rastinuser 创建架构授权中心 将persistence.xml更改为以下两行: 但问题已经存在 有人能帮忙吗hibernate找不到模式,hibernate,postgresql,wildfly,Hibernate,Postgresql,Wildfly,拥有wildfly 8.2.0 有一个postgres数据库和一个名为“authorization_central”的模式 实体模式为: persistence.xml是 发送给我错误: 错误[org.hibernate.engine.jdbc.spi.SqlExceptionHelper]未找到默认任务7架构授权\u中心;SQL语句: 在authorization_central.tblusers中插入密码、用户名、id值?、?、?[90079-173] 然后创建了一个名为rastinuser
谢天谢地。PostgreSQL区分大小写,请在此处查阅,可能会有所帮助。好的。但我认为不要使用大写字母,这会导致错误。您是否看到任何可能导致错误的大写字母?错误消息确实以大写字母显示名称,它看起来好像在某处使用过。检查postgresql日志以从数据库获取整个查询和原始错误消息。如果有必要,请打开日志记录,这在开发过程中非常有用。在哪里可以使用日志记录?如果看到上面的my\dn命令,则显示模式的小写字母。在java中也只使用小写。hibernate是否可以将我的模式转换为大写?@user2880318您是否尝试过在评论中提供的帖子中提供的解决方案。
@XmlRootElement(name = "users")
@Entity
@Table(name = "tblusers", schema = "authorization_central")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String userName;
private String password;
@XmlElement
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@XmlElement
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof User)) {
return false;
}
User other = (User) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "domain.models.User[ id=" + id + " ]";
}
}
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence">
<persistence-unit name="UserPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>domain.models.User</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/postgres"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.password" value="1234"/>
<!--<property name="javax.persistence.jdbc.user" value="rastin"/>-->
<!--<property name="javax.persistence.jdbc.password" value="bt_Ummah"/>-->
<!--<property name="javax.persistence.schema-generation.database.action" value="create"/>-->
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
@Transactional
public class EntityDao {
@PersistenceContext(name = "UserPersistenceUnit")
EntityManager entityManager;
public void add(Object t) {
try {
System.out.println("start adding4.");
if (entityManager == null) {
System.out.println("entity manager is null.");
entityManager = Persistence.
createEntityManagerFactory("UserPersistenceUnit").
createEntityManager();
if (entityManager != null) {
System.out.println("entity manager created.");
}
}
// entityManager.getTransaction().begin();
entityManager.persist(t);
// entityManager.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/rastindb"/>
<property name="javax.persistence.jdbc.user" value="rastinuser"/>
List of schemas
Name | Owner
-----------------------+------------
authorization_central | rastinuser
public | postgres