All Downloads are FREE. Search and download functionalities are using the official Maven repository.

link.jfire.sql.field.impl.WFloatField Maven / Gradle / Ivy

package link.jfire.sql.field.impl;

import java.lang.reflect.Field;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

@SuppressWarnings("restriction")
public class WFloatField extends AbstractMapField
{
    
    public WFloatField(Field field)
    {
        super(field);
    }
    
    @Override
    public void setEntityValue(Object entity, ResultSet resultSet) throws SQLException
    {
        float value = resultSet.getFloat(dbColName);
        if (resultSet.wasNull())
        {
            unsafe.putObject(entity, offset, null);
        }
        else
        {
            unsafe.putObject(entity, offset, value);
        }
    }
    
    @Override
    public void setStatementValue(PreparedStatement statement, Object entity, int index) throws SQLException
    {
        Float value = (Float) unsafe.getObject(entity, offset);
        if (value == null)
        {
            statement.setObject(index, null);
        }
        else
        {
            statement.setFloat(index, value);
        }
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy