You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public Long apply(final SQLUpdateClause update)
{
return update
.where(MY_TABLE.ID.eq(id))
.setNull(MY_TABLE.SOMETHING)
.execute();
}
As part of my Configuration, I have an SQLListener implementation that logs all SQL generated using an SQLSerializer (so for the update statement above, serializer.serializeUpdate() is called). I call setUseLiterals(true) on the serializer I use.
This throws the following exception when it attempts to serialize the SQL:
java.lang.IllegalArgumentException: Found no type for com.mysema.query.sql.types.Null
at com.mysema.query.sql.JavaTypeMapping.getType(JavaTypeMapping.java:133)
at com.mysema.query.sql.Configuration.asLiteral(Configuration.java:89)
at com.mysema.query.sql.SQLSerializer.visitConstant(SQLSerializer.java:729)
at com.mysema.query.support.SerializerBase.visit(SerializerBase.java:208)
at com.mysema.query.support.SerializerBase.visit(SerializerBase.java:42)
at com.mysema.query.types.ConstantImpl.accept(ConstantImpl.java:127)
at com.mysema.query.support.SerializerBase.handle(SerializerBase.java:105)
at com.mysema.query.sql.SQLSerializer.serializeForUpdate(SQLSerializer.java:574)
at com.mysema.query.sql.SQLTemplates.serializeUpdate(SQLTemplates.java:800)
at com.mysema.query.sql.SQLSerializer.serializeUpdate(SQLSerializer.java:544)
at com.atlassian.pocketknife.api.querydsl.LoggingSqlListener.getUpdateSql(LoggingSqlListener.java:202)
at com.atlassian.pocketknife.api.querydsl.LoggingSqlListener.notifyUpdate(LoggingSqlListener.java:106)
I'm able to work around this by calling configuration.register(new NullType()) on the configuration used when executing the update, where NullType is this class I created:
public class NullType extends AbstractType<Null>
{
public NullType() {
super(Types.NULL);
}
@Override
public Null getValue(ResultSet rs, int startIndex) throws SQLException {
return Null.DEFAULT;
}
@Override
public Class<Null> getReturnedClass() {
return Null.class;
}
@Override
public void setValue(PreparedStatement st, int startIndex, Null value)
throws SQLException {
if(isNotEmpty(getSQLTypes()))
{
st.setNull(startIndex, getSQLTypes()[0]);
}
else
{
throw new RuntimeException("Unable to set database column to null");
}
}
@Override
public String getLiteral(final Null value)
{
return "null";
}
}
Null is a pretty standard database type, so I think this should be part of the default supported types (defaultTypes in JavaTypeMapping).
The text was updated successfully, but these errors were encountered:
I have the following update statement:
As part of my Configuration, I have an
SQLListener
implementation that logs all SQL generated using anSQLSerializer
(so for the update statement above,serializer.serializeUpdate()
is called). I callsetUseLiterals(true)
on the serializer I use.This throws the following exception when it attempts to serialize the SQL:
I'm able to work around this by calling
configuration.register(new NullType())
on the configuration used when executing the update, whereNullType
is this class I created:Null is a pretty standard database type, so I think this should be part of the default supported types (
defaultTypes
inJavaTypeMapping
).The text was updated successfully, but these errors were encountered: