In two words:
transforms into incorrect query by HibernateDataSource, which doesn't return records with foreignKey == null (what for is the second join?)
In Detail:
I have a ListGrid with a list of users. There's a department FK field there. When i try to sort data by this field things go bad, listgrid shows records with foreignKey != null and starts to infinitely make tries to reload recordset.
users.ds.xml
User.java
nothing special about listgrid
Also i have department.ds.xml and Department hibernate bean. Nothing special about them, just id and name fields. And i also tried declaring foreignKey="departments.id" (despite the fact that it should be autoloaded from bean defintition).
Am i missing something? Please help. All Your examples doesn't provide the case where FK can be null.
I can provide full logs on demand.
TY.
Code:
INFO HibernateDataSource - [builtinApplication.users_fetch] Query string: select _User, department1 from ru.eurotechnologygroup.etgcrm.server.model.User _User left outer join _User.department department1 order by _User.department.name
Code:
DEBUG SQL - select top 75 user0_.USERID as USERID0_0_, department1_.DID as DID2_1_, user0_.USERBLOCKED as USERBLOC2_0_0_, user0_.USERDATEBIRTH as USERDATE3_0_0_, user0_.DID as DID0_0_, user0_.USEREMAIL as USEREMAIL0_0_, user0_.USERFIRSNAME as USERFIRS5_0_0_, user0_.USERLASTNAME as USERLAST6_0_0_, user0_.USERLOGIN as USERLOGIN0_0_, user0_.USERMASKIP as USERMASKIP0_0_, user0_.USERPASSWORD as USERPASS9_0_0_, user0_.USERPHONE as USERPHONE0_0_, user0_.USERPATRONYMIC as USERPAT11_0_0_, department1_.DNAME as DNAME2_1_ from suser user0_ left outer join department department1_ on user0_.DID=department1_.DID cross join department department2_ where user0_.DID=department2_.DID order by department2_.DNAME
I have a ListGrid with a list of users. There's a department FK field there. When i try to sort data by this field things go bad, listgrid shows records with foreignKey != null and starts to infinitely make tries to reload recordset.
users.ds.xml
Code:
<DataSource ID="users" serverType="hibernate" beanClassName="ru.eurotechnologygroup.etgcrm.server.model.User"
schemaBean="ru.eurotechnologygroup.etgcrm.server.model.User">
<fields>
...
<field name="departmentName" type="text" hidden="true" valueXPath="department/name"/>
<field name="department" title="Подразделение" displayField="departmentName"/>
...
</fields>
</DataSource>
Code:
@Entity
@Table(name = "suser")
public class User implements Serializable
{
...
private Department department;
...
@OneToOne(targetEntity = Department.class, fetch = FetchType.EAGER)
@JoinColumn(name = "DID")
public Department getDepartment()
{
return department;
}
public void setDepartment(Department department)
{
this.department = department;
}
}
Code:
DataSource ds = DataSource.get("users");
ListGrid listGrid = new ListGrid();
listGrid.setCanEdit(false);
listGrid.setDataSource(ds);
listGrid.setAutoFetchData(true);
Am i missing something? Please help. All Your examples doesn't provide the case where FK can be null.
I can provide full logs on demand.
TY.
Comment