Jakarta ee hibernate追加";0“;到表名
我有一个运行在wildfly 8.2上的J2EE7Web应用程序。数据库是H2。这是我的实体类Jakarta ee hibernate追加";0“;到表名,jakarta-ee,h2,wildfly-8,Jakarta Ee,H2,Wildfly 8,我有一个运行在wildfly 8.2上的J2EE7Web应用程序。数据库是H2。这是我的实体类 @MappedSuperclass public class AbstractEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; //Getters/Setters are he
@MappedSuperclass
public class AbstractEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//Getters/Setters are here
}
@Entity
public class Patient extends AbstractEntity {
private String firstName;
private String lastName;
private Date DOB;
//Setters/Getters are here
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="patient-pu" transaction-type="JTA">
<jta-data-source>java:jboss/h2</jta-data-source>
<class>com.example.backend.Patient</class>
</persistence-unit>
</persistence>
如果Hibernate没有添加任何内容,请查看查询:
select patient0_.id as id1_0_,
patient0_.DOB as DOB2_0_,
patient0_.firstName as firstNam3_0_,
patient0_.lastName as lastName4_0_
from Patient patient0_
你可以看到patient0_uu只是一个别名。该错误表示您的患者表中没有DOB列。你确定有DOB列吗?也许这个案例有问题,并且确实存在小写的dob,那么您必须映射如下
@Column(name="dob")
private Date DOB;
我的错。它是数据库中的DBO。我把它改了,现在可以用了。谢谢
@Column(name="dob")
private Date DOB;