我正在尝试实现简单的 Spring Data 应用程序。我有一个简单的实体 Employee 和几个字段,我使用 CrudRepository: findById 中的方法从数据库中检索员工。但结果总是为空,实体中唯一的ID字段是正确的,但其他字段为空。即使我试图获取 findAll() 然后我也从表中获取了所有记录,但它们只有 ID 字段,没有别的。
我不使用插件只是 Hibernate .hbm.xml 的 XML 文件。使用 hbm.xml 看起来实体如何:
员工实体:
public class Employee extends BaseEntity {
private static final long serialVersionUID = -1400760321767476971L;
private String empFirstName;
private String empPassword;
private String empRole;
private String empLastName;
private String empBirthDate;
private String empAvatar;
private Integer empDepartmentId;
private Integer empEnabled;
private Integer empPositionId;
private Integer empManagerId;
private Integer empIsManager;
private String empEvidenceNumber;
private Double empAreaOfWork;
private Integer empWorkingHoursPerDay;
private String empFirstWorkDay;
...getters/setters/constructors
员工.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="entity.Employee" table="vt_employee" catalog="VacationTool"
optimistic-lock="version">
<id name="id" type="java.lang.Integer">
<column name="id_employee" />
<generator class="identity" />
</id>
<property name="empPassword" type="string">
<column name="emp_password" length="60" />
</property>
<property name="empRole" type="string">
<column name="emp_role" length="45" />
</property>
<property name="empEnabled" type="java.lang.Integer">
<column name="emp_enabled" />
</property>
<property name="empFirstName" type="string">
<column name="emp_firstName" length="75" />
</property>
<property name="empLastName" type="string">
<column name="emp_lastName" length="75" />
</property>
<property name="empBirthDate" type="string">
<column name="emp_birthDate" length="10" />
</property>
<property name="empAvatar" type="string">
<column name="emp_avatar" />
</property>
慕姐4208626
相关分类