Hi,
I have a problem with the sizeEq method in Restriction class.
The only difference is that im working with a Mysql 5.0 and the production database is Mysql 4.0. Everything else is the same. Hibernate 3.2 and tomcat 5.5.
I have seen this bug
http://lists.jboss.org/pipermail/hibern ... 00197.html
but it says it is solved.
I have this class:
Code:
public class Person {
protected long id;
protected String name;
protected Set<Sector> sectors;
}
with this mapping
Code:
<hibernate-mapping>
<class name="org.foo.Person" table="Person" lazy="false">
<id name="id" column="PERSON_ID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" not-null="true"/>
<set name="sectors" table="PERSONS_TO_SECTORS">
<key column="PERSON_ID"/>
<many-to-many column="SECTOR_ID"
class="org.foo.Sector"/>
</set>
</class>
</hibernate-mapping>
and then in my DAO i have the following code:
Code:
public List<Persont> findWithTwoSectors(Person exampleInstance, String[] excludeProperty) {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance).ignoreCase().excludeZeroes().enableLike();
for (String exclude : excludeProperty) {
example.excludeProperty(exclude);
}
crit.add(example);
crit.add(Restrictions.sizeEq("sectors", 2));
return crit.list();
}
I have been working with this code on a test database and it was working fine but now i found that it doesn't work on the production database and the stacktrace says:
Code:
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from PERSONS_TO_SECTORS where this_.PERSON
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
Is there any solution or workaround to this??
Thank you