org.hibernate.type.IntegerType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.type;
import java.io.Serializable;
import java.util.Comparator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.IntegerTypeDescriptor;
/**
* A type that maps between {@link java.sql.Types#INTEGER INTEGER} and @link Integer}
*
* @author Gavin King
* @author Steve Ebersole
*/
public class IntegerType extends AbstractSingleColumnStandardBasicType
implements PrimitiveType, DiscriminatorType, VersionType {
public static final IntegerType INSTANCE = new IntegerType();
public static final Integer ZERO = 0;
public IntegerType() {
super( org.hibernate.type.descriptor.sql.IntegerTypeDescriptor.INSTANCE, IntegerTypeDescriptor.INSTANCE );
}
@Override
public String getName() {
return "integer";
}
@Override
public String[] getRegistrationKeys() {
return new String[] {getName(), int.class.getName(), Integer.class.getName()};
}
@Override
public Serializable getDefaultValue() {
return ZERO;
}
@Override
public Class getPrimitiveClass() {
return int.class;
}
@Override
public String objectToSQLString(Integer value, Dialect dialect) throws Exception {
return toString( value );
}
@Override
public Integer stringToObject(String xml) {
return fromString( xml );
}
@Override
public Integer seed(SharedSessionContractImplementor session) {
return ZERO;
}
@Override
public Integer next(Integer current, SharedSessionContractImplementor session) {
return current + 1;
}
@Override
public Comparator getComparator() {
return getJavaTypeDescriptor().getComparator();
}
}