Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle 从resultset休眠不正确的分组_Oracle_Hibernate_Jdbc_Oracle12c - Fatal编程技术网

Oracle 从resultset休眠不正确的分组

Oracle 从resultset休眠不正确的分组,oracle,hibernate,jdbc,oracle12c,Oracle,Hibernate,Jdbc,Oracle12c,我正在尝试使用Hibernate检索一个实体及其子实体。它大部分时间都很好用。但是,有时子实体分组不正确,这是随机发生的。让我试着解释一下 我的实体类- 员工(母公司): EmployeeRolePK(EmployeeRole的主键): 获取员工和员工角色的标准: Criteria criteria = this.getSession().createCriteria(Employee.class); criteria.add(Restrictions.in("id", parameterLis

我正在尝试使用Hibernate检索一个实体及其子实体。它大部分时间都很好用。但是,有时子实体分组不正确,这是随机发生的。让我试着解释一下

我的实体类-

员工(母公司):

EmployeeRolePK(EmployeeRole的主键):

获取员工和员工角色的标准:

Criteria criteria = this.getSession().createCriteria(Employee.class);
criteria.add(Restrictions.in("id", parameterList));
List<Employee> entities = criteria.list()

这可能是什么原因?非常感谢您的帮助。谢谢
版本:Hibernate 4.2.8,commons dbcp 1.4

编辑:经过多次重试,我们已经将问题范围缩小到JDBC驱动程序或Oracle本身。我们通过JDBC运行hibernate生成的查询,遇到了相同的问题。我们还发现了一种模式来重新创建此错误传递随机输入参数,但第一次失败。如果使用相同的参数重试,则效果良好。我们也曾在SQLDeveloper中看到过这个错误。
以下是问题-

select emprole0_.EMP_ID as EMP_2_49_1_, emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_1_, emprole0_.EMP_ID as EMP_2_25_1_, 
emprole0_.ROLE_ID as ROLE_ID3_25_1_, emprole0_.ROLE_TYP as ROLE_TYP4_25_1_, 
emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_0_, emprole0_.EMP_ID as EMP_2_25_0_,
emprole0_.ROLE_ID as ROLE_ID3_25_0_, emprole0_.ROLE_TYP as ROLE_TYP4_25_0_, emprole0_.EMP_ROLE_EXPT_DT as EMP_ROLE5_25_0_ 
from EMP_ROLE emprole0_ where emprole0_.EMP_ID in (
select this_.EMP_ID from EMP this_ where this_.EMP_ID in (?, ?, ?)
)

如果删除了内部查询,则每次都可以正常运行。但是对于内部查询,结果有时是不正确的。我猜SQLDeveloper也使用JDBC驱动程序,所以这似乎是一个驱动程序问题。我们可能会尝试使用SQLPlus



版本-Oracle 12c、ojdbc7

您可以使用不同的角色ID准备数据吗?对于DB中的每一行,都将是不同的,我们可以在更新角色id和仅重复员工id后判断此日期是否重复,或者mappingI检查是否有问题。我已经更新了数据集。我已经用最新的发现更新了问题。。这似乎是JDBC驱动程序的问题。
@Embeddable
public class EmployeeRolePK {

    @Column(name="EMP_ID")
    private String empId;

    @Column(name="ROLE_ID")
    private long roleId;

    @Column(name="ROLE_TYP")
    private String roleTyp;

    @Column(name="EMP_ROLE_EFF_DT")
    @Type(type = "org.jadira.usertype.dateandtime.threeten.PersistentLocalDate")
    private LocalDate empRoleEffDate;

    //--Getters and Setters--

    public boolean equals(Object other) {
        // --NUll and InstanceOf checks--
        EmployeeRolePK castOther = (EmployeeRolePK)other;
        return this.empId.equals(castOther.empId) && (this.roleId == castOther.roleId) 
            && this.roleTyp.equals(castOther.roleTyp) && this.empRoleEffDate.equals(castOther.empRoleEffDate);
    }

    public int hashCode() {
        final int prime = 31;
        int hash = 17;
        hash = hash * prime + this.empId.hashCode();
        hash = hash * prime + ((int) (this.roleId ^ (this.roleId >>> 32)));
        hash = hash * prime + this.roleTyp.hashCode();
        hash = hash * prime + this.empRoleEffDate.hashCode();
        return hash;
    }
}
Criteria criteria = this.getSession().createCriteria(Employee.class);
criteria.add(Restrictions.in("id", parameterList));
List<Employee> entities = criteria.list()
| EMP_ID | ROLE_ID | ROLE_TYP | EMP_ROLE_EFF_DT | EMP_ROLE_EXPT_DT |
|--------|---------|----------|-----------------|------------------|
|     E1 |    1111 |       T1 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
|     E1 |    2222 |       T2 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
|     E2 |    3333 |       T1 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
|     E2 |    4444 |       T2 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
|     E3 |    1111 |       T1 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
|     E3 |    2222 |       T2 |      2017-05-01 |           <null> |
|--------|---------|----------|-----------------|------------------|
2017-06-02 19:13:45,653 DEBUG  ?#?:? Static select for one-to-many com.test.Employee.empRoles: select emprole0_.EMP_ID as EMP_2_49_1_, emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_1_, emprole0_.EMP_ID as EMP_2_25_1_, emprole0_.ROLE_ID as ROLE_ID3_25_1_, emprole0_.ROLE_TYP as ROLE_TYP4_25_1_, emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_0_, emprole0_.EMP_ID as EMP_2_25_0_, emprole0_.ROLE_ID as ROLE_ID3_25_0_, emprole0_.ROLE_TYP as ROLE_TYP4_25_0_, emprole0_.EMP_ROLE_EXPT_DT as EMP_ROLE5_25_0_ from EMP_ROLE emprole0_ where emprole0_.EMP_ID in (select this_.EMP_ID from EMP this_ where this_.EMP_ID in (?, ?, ?))
2017-06-02 19:13:45,654 TRACE  ?#?:? binding parameter [1] as [VARCHAR] - E1
2017-06-02 19:13:45,654 TRACE  ?#?:? binding parameter [2] as [VARCHAR] - E2
2017-06-02 19:13:45,654 TRACE  ?#?:? binding parameter [3] as [VARCHAR] - E3
2017-06-02 19:13:45,666 DEBUG  ?#?:? Result set row: 0
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [E1] as column [EMP_2_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [1111] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [T1] as column [ROLE_TYP4_25_0_]
2017-06-02 19:13:45,666 DEBUG  ?#?:? Result set row: 1
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [E1] as column [EMP_2_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [2222] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,666 TRACE  ?#?:? Found [T2] as column [ROLE_TYP4_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Result set row: 2
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [E3] as column [EMP_2_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [3333] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [T1] as column [ROLE_TYP4_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Result set row: 3
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [E3] as column [EMP_2_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [4444] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [T2] as column [ROLE_TYP4_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Result set row: 4
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [E3] as column [EMP_2_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [1111] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,668 TRACE  ?#?:? Found [T1] as column [ROLE_TYP4_25_0_]
2017-06-02 19:13:45,669 DEBUG  ?#?:? Result set row: 5
2017-06-02 19:13:45,669 TRACE  ?#?:? Found [2017-05-01] as column [EMP_ROLE1_25_0_]
2017-06-02 19:13:45,669 TRACE  ?#?:? Found [E3] as column [EMP_2_25_0_]
2017-06-02 19:13:45,669 TRACE  ?#?:? Found [2222] as column [ROLE_ID3_25_0_]
2017-06-02 19:13:45,669 TRACE  ?#?:? Found [T2] as column [ROLE_TYP4_25_0_]
select emprole0_.EMP_ID as EMP_2_49_1_, emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_1_, emprole0_.EMP_ID as EMP_2_25_1_, 
emprole0_.ROLE_ID as ROLE_ID3_25_1_, emprole0_.ROLE_TYP as ROLE_TYP4_25_1_, 
emprole0_.EMP_ROLE_EFF_DT as EMP_ROLE1_25_0_, emprole0_.EMP_ID as EMP_2_25_0_,
emprole0_.ROLE_ID as ROLE_ID3_25_0_, emprole0_.ROLE_TYP as ROLE_TYP4_25_0_, emprole0_.EMP_ROLE_EXPT_DT as EMP_ROLE5_25_0_ 
from EMP_ROLE emprole0_ where emprole0_.EMP_ID in (
select this_.EMP_ID from EMP this_ where this_.EMP_ID in (?, ?, ?)
)