相关文章
更多最近更新
更多spring+hibernate+mysql执行HQL查询报未打开游标错误
2019-03-25 13:47|来源: 网路
spring配置:
执行HibernateTemplate的HQL查询语句(如:getHibernateTemplate().find("from SysUser")方法)时候报错: The statement (1) has no open cursor.
有遇到过同样问题的吗?
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/jdbc/MY</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQL5InnoDBDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.max_fetch_depth">0</prop> <prop key="hibernate.jdbc.fetch_size">100</prop> <prop key="hibernate.jdbc.batch_size">50</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/>
执行HibernateTemplate的HQL查询语句(如:getHibernateTemplate().find("from SysUser")方法)时候报错: The statement (1) has no open cursor.
有遇到过同样问题的吗?
相关问答
更多-
如何用Joda Time在HQL(Hibernate)中查询日期?(How to query a date in HQL (Hibernate) with Joda Time?)[2023-10-20]
我不是Grails专家,但是在java中,您通常会使用date1和date2查询参数并将它们绑定为: String hql = "select * from Book as b where b.releaseDate > :date1 and b.releaseDate < :date2"; session.createQuery(hql).setDate("date1", date1).setDate("date2", date2).list(); 我相信你可以在Grails中做类似的事情。 如果没有, ... -
我不愿意这样做,但经过一些研究,我只能考虑使用SQL查询。 就像是 : String sQuery = "SELECT SUM(case when max_amount is null then price ... final org.hibernate.SQLQuery query = session.createSQLQuery(sQuery); List results = query.list(); 我无法想到Hibernate使用HQL处理嵌套查询。 I was reluctant to do ...
-
而不是SELECT u FROM Utilisateur使用SELECT u FROM User 。 我们应该使用实体名称而不是表名。 Instead of SELECT u FROM Utilisateur use SELECT u FROM User in the @Query. We should use entity name rather than table name.
-
用HQL查询Hibernate(Query in Hibernate with HQL)[2022-07-25]
我认为你没有正确建立实体之间的关系。 @ForeignKey表示约束,但不表示java实体之间的关系本身。 在Hibernate 5.1版本之前,如果您之前没有使用@OneToOne, @OneToMany, @ManyToOne等注释建立它们之间的关系,则不能在JPQL中使用实体之间的连接... ...有关此主题以及如何加入无关的更多信息实体。 要执行查询,您必须在实体中定义类似的内容 @Entity @Table(name="TB_Person") public class TB_Person { ... -
你可以尝试像下面那样指定模式。 @Entity @Table(name = "vivax.Category") You can try specifying the schema like below. @Entity @Table(name = "vivax.Category")
-
Hibernate(HQL) - 如何查询“many in()”中的多对多(Hibernate(HQL) - how to query “where many in()” many to many)[2022-01-16]
未定义用户别名。 试试吧 String hql = "from User user inner join user.cars car where car.id in (:carIds)"; Query query = session.createQuery(hql) query.setParameterList("cars", carIds); 其中carIds是一个集合(而不是第三次尝试中的字符串),其中包含汽车的ID。 The user alias is not defined. Try with S ... -
Hibernate HQL子查询(Hibernate HQL Subquery)[2024-02-07]
我修这个SQL: SELECT tag, (SELECT count(yt.id) FROM yp_user_tag yut INNER JOIN yp_tag yt ON yut.tag_id=yt.id WHERE tag.id=yt.id GROUP BY tag_id) as m, (SELECT count(*) as metric FROM yp_promotion_tag ypt ... -
我不知道executeNamedQuery什么executeNamedQuery ,但似乎你的更改没有提交给数据库。 在这种情况下,upate将在事务超时后回滚。 I don´t know whats around executeNamedQuery, but it seems that your changes are not committed to the database. In that case the upate will be rolled back after transaction ti ...
-
hibernate HQL元素错误(hibernate HQL elements error)[2023-11-03]
我认为你需要明确加入 。 select distinct hibuser from HibernateUserImpl hibuser join hibuser.groups hibgroup where hibuser.name = ? and hibgroup.name = ? I think you need to make an explicit join. select distinct hibuser from HibernateUserI ... -
我遇到的问题与Spring Jira Issue SPR-13848中描述的完全相同 。 据我了解,似乎OpenSessionInViewFilter提前打开了一个请求范围的会话,并且存在与稍后启动的事务同步的问题。 我无法摆脱我的OSIV,因为它会在整个应用程序中产生影响。 但是,我发现hibernate有一个属性可以完成类似的事情以防止延迟加载 -
true 这解决了这个问题。 添加此属性允许 ...