use of org.hibernate.type.SerializableType in project hibernate-orm by hibernate.
the class QueryParameterBindingsImpl method collectPositionalBindTypes.
/**
* @deprecated (since 5.2) expect a different approach to org.hibernate.engine.spi.QueryParameters in 6.0
*/
@Deprecated
public Type[] collectPositionalBindTypes() {
Type[] types = new Type[positionalParameterBindings.size()];
for (Map.Entry<Integer, QueryParameterBinding> entry : positionalParameterBindings.entrySet()) {
final int position = entry.getKey();
Type type = entry.getValue().getBindType();
if (type == null) {
log.debugf("Binding for positional-parameter [%s] did not define type, using SerializableType", position);
type = SerializableType.INSTANCE;
}
types[position] = type;
}
return types;
}
use of org.hibernate.type.SerializableType in project hibernate-orm by hibernate.
the class Java8DateTimeTests method basicTests.
@Test
public void basicTests() {
final PersistentClass entityBinding = metadata().getEntityBinding(TheEntity.class.getName());
final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator();
while (propertyBindingIterator.hasNext()) {
final Property propertyBinding = (Property) propertyBindingIterator.next();
assertFalse("Found property bound as Serializable : " + propertyBinding.getName(), propertyBinding.getType() instanceof SerializableType);
}
TheEntity theEntity = new TheEntity(1);
Session s = openSession();
s.beginTransaction();
s.save(theEntity);
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
theEntity = (TheEntity) s.get(TheEntity.class, 1);
dump(entityBinding, theEntity);
assertNotNull(theEntity);
s.delete(theEntity);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.type.SerializableType in project hibernate-orm by hibernate.
the class SessionFactoryImpl method resolveParameterBindType.
@Override
public Type resolveParameterBindType(Class clazz) {
String typename = clazz.getName();
Type type = getTypeResolver().heuristicType(typename);
boolean serializable = type != null && type instanceof SerializableType;
if (type == null || serializable) {
try {
getMetamodel().entityPersister(clazz.getName());
} catch (MappingException me) {
if (serializable) {
return type;
} else {
throw new HibernateException("Could not determine a type for class: " + typename);
}
}
return getTypeHelper().entity(clazz);
} else {
return type;
}
}
Aggregations