One-root-entity-per-returned-row phenomenon of hibernate
来源:互联网 发布:java怎么编写分段函数 编辑:程序博客网 时间:2024/06/05 20:38
public static List t() ...{
List r = new ArrayList();
Session s = Sf.getSession();
Transaction tx;
tx = s.beginTransaction();
String sql;
try ...{
r = s.createCriteria(JtsUser.class)
.add(Restrictions.idEq(2))
.setFetchMode("jtsHistories", FetchMode.JOIN)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.list();
tx.commit();
} catch (Exception e) ...{
e.printStackTrace();
tx.rollback();
} finally ...{
s.close();
}
return r;
}
public static List tt() ...{
List r = new ArrayList();
Session s = Sf.getSession();
Transaction tx;
tx = s.beginTransaction();
String sql;
try ...{
r = s.createCriteria(JtsUser.class)
.add(Restrictions.idEq(2))
.setFetchMode("jtsHistories", FetchMode.JOIN)
.list();
tx.commit();
} catch (Exception e) ...{
e.printStackTrace();
tx.rollback();
} finally ...{
s.close();
}
return r;
}
List r = new ArrayList();
Session s = Sf.getSession();
Transaction tx;
tx = s.beginTransaction();
String sql;
try ...{
r = s.createCriteria(JtsUser.class)
.add(Restrictions.idEq(2))
.setFetchMode("jtsHistories", FetchMode.JOIN)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.list();
tx.commit();
} catch (Exception e) ...{
e.printStackTrace();
tx.rollback();
} finally ...{
s.close();
}
return r;
}
public static List tt() ...{
List r = new ArrayList();
Session s = Sf.getSession();
Transaction tx;
tx = s.beginTransaction();
String sql;
try ...{
r = s.createCriteria(JtsUser.class)
.add(Restrictions.idEq(2))
.setFetchMode("jtsHistories", FetchMode.JOIN)
.list();
tx.commit();
} catch (Exception e) ...{
e.printStackTrace();
tx.rollback();
} finally ...{
s.close();
}
return r;
}
t().size() is 1; While tt().size() is 4, that's the one-root-entity-per-returned-row phenomenon of hibernate.
Add "setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)" to eliminate the one-root-entity-per-returned-row phenomenon that you're seeing.
- One-root-entity-per-returned-row phenomenon of hibernate
- one case of Hibernate error:could not load an entity
- Result consisted of more than one row
- Result consisted of more than one row
- Explanation of Small World Phenomenon
- mybatis中:returned more than one row, where no more than one was expected
- Mybatis中关于:Statement returned more than one row, where no more than one was expected.
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException: Batch update returned unexpected row cou...
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- The "Run One Program Only" Phenomenon
- hibernate 错误 Batch update returned unexpected row count from update [0]; actual row count: 0;
- Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected:
- Hibernate 报错:Batch update returned unexpected row count from update [0]; actual row count
- Hibernate:Batch update returned unexpected row count from update [0]; actual row count: 0; expected:
- Hibernate——org.hibernate.StaleStateException: Batch update returned unexpected row count from update
- Result consisted of more than one row 错误的解决
- 你是最棒的!
- 你应当如何学习C++(以及编程)(rev#1)
- ASP.NET中GridView的自定义分页
- C#执行存储过程
- 无刷新联动菜单
- One-root-entity-per-returned-row phenomenon of hibernate
- 两个不错的下拉式日期选择控件
- 利用Visual C#打造一个平滑的进度条
- Hello ASP.NET AJAX
- HEARTS, CLUBS, DIAMONDS, SPADES: PLAYERS WHO SUIT MUDS
- 如何编写一个shell脚本
- skin的初级应用[制作skin][应用skin][编程使用skin]
- QuickSort
- Access中的模糊查询