use of org.hibernate.type.IntegerType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testGetPrimitiveClass.
@Test
public void testGetPrimitiveClass() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertNull(typeFacade.getPrimitiveClass());
IntegerType integerType = new IntegerType();
typeFacade = FACADE_FACTORY.createType(integerType);
assertEquals(int.class, typeFacade.getPrimitiveClass());
}
use of org.hibernate.type.IntegerType in project dhis2-core by dhis2.
the class HibernatePropertyIntrospector method createProperty.
private Property createProperty(Class<?> klass, org.hibernate.mapping.Property hibernateProperty, MetamodelImplementor metamodelImplementor) {
Property property = new Property(klass);
property.setRequired(false);
property.setPersisted(true);
property.setWritable(true);
property.setOwner(true);
Type type = hibernateProperty.getType();
property.setName(hibernateProperty.getName());
property.setFieldName(hibernateProperty.getName());
property.setCascade(hibernateProperty.getCascade());
property.setCollection(type.isCollectionType());
property.setSetterMethod(hibernateProperty.getSetter(klass).getMethod());
property.setGetterMethod(hibernateProperty.getGetter(klass).getMethod());
if (property.isCollection()) {
initCollectionProperty(metamodelImplementor, property, (CollectionType) type);
}
if (type instanceof SingleColumnType || type instanceof CustomType || type instanceof ManyToOneType) {
Column column = (Column) hibernateProperty.getColumnIterator().next();
property.setUnique(column.isUnique());
property.setRequired(!column.isNullable());
property.setMin(0d);
property.setMax((double) column.getLength());
property.setLength(column.getLength());
if (type instanceof TextType) {
property.setMin(0d);
property.setMax((double) Integer.MAX_VALUE);
property.setLength(Integer.MAX_VALUE);
} else if (type instanceof IntegerType) {
property.setMin((double) Integer.MIN_VALUE);
property.setMax((double) Integer.MAX_VALUE);
property.setLength(Integer.MAX_VALUE);
} else if (type instanceof LongType) {
property.setMin((double) Long.MIN_VALUE);
property.setMax((double) Long.MAX_VALUE);
property.setLength(Integer.MAX_VALUE);
} else if (type instanceof DoubleType) {
property.setMin(-Double.MAX_VALUE);
property.setMax(Double.MAX_VALUE);
property.setLength(Integer.MAX_VALUE);
}
}
if (type instanceof ManyToOneType) {
property.setManyToOne(true);
property.setRequired(property.isRequired() && !property.isCollection());
if (property.isOwner()) {
property.setOwningRole(klass.getName() + "." + property.getName());
} else {
property.setInverseRole(klass.getName() + "." + property.getName());
}
} else if (type instanceof OneToOneType) {
property.setOneToOne(true);
} else if (type instanceof OneToMany) {
property.setOneToMany(true);
}
return property;
}
use of org.hibernate.type.IntegerType in project BroadleafCommerce by BroadleafCommerce.
the class GenericEntityDaoImpl method readGenericEntity.
@Override
public <T> T readGenericEntity(Class<T> clazz, Object id) {
clazz = (Class<T>) DynamicDaoHelperImpl.getNonProxyImplementationClassIfNecessary(clazz);
Map<String, Object> md = daoHelper.getIdMetadata(clazz, (HibernateEntityManager) em);
AbstractSingleColumnStandardBasicType type = (AbstractSingleColumnStandardBasicType) md.get("type");
if (type instanceof LongType) {
id = Long.parseLong(String.valueOf(id));
} else if (type instanceof IntegerType) {
id = Integer.parseInt(String.valueOf(id));
}
return em.find(clazz, id);
}
use of org.hibernate.type.IntegerType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsIntegerType.
@Test
public void testIsIntegerType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isIntegerType());
IntegerType integerType = new IntegerType();
typeFacade = FACADE_FACTORY.createType(integerType);
assertTrue(typeFacade.isIntegerType());
}
use of org.hibernate.type.IntegerType in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testGetPrimitiveClass.
@Test
public void testGetPrimitiveClass() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertNull(typeFacade.getPrimitiveClass());
IntegerType integerType = new IntegerType();
typeFacade = FACADE_FACTORY.createType(integerType);
assertEquals(int.class, typeFacade.getPrimitiveClass());
}
Aggregations