1
//$Id: BooleanType.java 7825 2005-08-10 20:23:55Z oneovthafew $
2
package org.hibernate.type;
4
import java.io.Serializable;
5
import java.sql.PreparedStatement;
6
import java.sql.ResultSet;
7
import java.sql.SQLException;
10
import org.hibernate.dialect.Dialect;
13
* <tt>boolean</tt>: A type that maps an SQL BIT to a Java Boolean.
16
public class BooleanType extends PrimitiveType implements DiscriminatorType {
18
public Serializable getDefaultValue() {
22
public Object get(ResultSet rs, String name) throws SQLException {
23
return rs.getBoolean(name) ? Boolean.TRUE : Boolean.FALSE;
26
public Class getPrimitiveClass() {
30
public Class getReturnedClass() {
34
public void set(PreparedStatement st, Object value, int index)
36
st.setBoolean( index, ( (Boolean) value ).booleanValue() );
39
public int sqlType() {
43
public String getName() { return "boolean"; }
45
public String objectToSQLString(Object value, Dialect dialect) throws Exception {
46
return dialect.toBooleanValueString( ( (Boolean) value ).booleanValue() );
49
public Object stringToObject(String xml) throws Exception {
50
return fromStringValue(xml);
53
public Object fromStringValue(String xml) {
54
return Boolean.valueOf(xml);