I have this query:
Code:
"SELECT COUNT( o.spoolSerial ) FROM MbiSpool AS o WHERE ( o.status = 0 and o.zpktStartZeit < :zpktStartZeit ) OR ( o.status = 1 )"
Status field in MbiSpool is defined this way:
Code:
/** Status. */
@Column( name = "status", nullable = false )
private BackgroundJobStatus status;
Using this attribute converter:
Code:
package biz.mbisoftware.fn.datatypes;
import javax.persistence.AttributeConverter;
public enum BackgroundJobStatus {
B_BACKSTART(0), B_BACKBEARB(1), B_BACKFEHLER(2), B_BACKOK(3);
final Integer value;
BackgroundJobStatus( final int value )
{
this.value = Integer.valueOf( value );
}
@javax.persistence.Converter(autoApply = true)
public static class Converter implements AttributeConverter<BackgroundJobStatus, Integer>
{
@Override
public Integer convertToDatabaseColumn( final BackgroundJobStatus value )
{
return value.value;
}
@Override
public BackgroundJobStatus convertToEntityAttribute( final Integer data )
{
BackgroundJobStatus rv = null;
for ( BackgroundJobStatus v : BackgroundJobStatus.values() ) {
if ( v.value.equals( data ) ) {
rv = v;
break;
}
}
return rv;
}
}
}
With ORM 5.0.1 the query above works, with 5.0.4 I get this exception:
Code:
Caused by: org.hibernate.QueryException: AttributeConverter domain-model attribute type [biz.mbisoftware.fn.datatypes.BackgroundJobS
tatus] did not match query literal type [java.lang.Integer]
at org.hibernate.hql.internal.ast.tree.LiteralNode.determineConvertedValue(LiteralNode.java:107)
at org.hibernate.hql.internal.ast.tree.LiteralNode.setExpectedType(LiteralNode.java:87)
at org.hibernate.hql.internal.ast.tree.BinaryLogicOperatorNode.initialize(BinaryLogicOperatorNode.java:62)
at org.hibernate.hql.internal.ast.HqlSqlWalker.prepareLogicOperator(HqlSqlWalker.java:1298)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4630)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2104)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2029)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2054)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:796)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:597)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)
How do I have to change my query for 5.04.? What would be the right way then?
Or is this a bug?