use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class LazyLoadingIntegrationTestTask method prepare.
public void prepare() {
Configuration cfg = new Configuration();
cfg.setProperty(Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
super.prepare(cfg);
Session s = getFactory().openSession();
s.beginTransaction();
Parent parent = new Parent();
parent.setChildren(new ArrayList<Child>(CHILDREN_SIZE));
for (int i = 0; i < CHILDREN_SIZE; i++) {
final Child child = new Child();
// Association management should kick in here
child.setParent(parent);
s.persist(child);
lastChildID = child.getId();
}
s.persist(parent);
parentID = parent.getId();
s.getTransaction().commit();
s.clear();
s.close();
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class SQLServerDialectTest method constructConfiguration.
@Override
protected Configuration constructConfiguration() {
Configuration configuration = super.constructConfiguration();
configuration.setProperty(AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, Boolean.TRUE.toString());
return configuration;
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class CriterionTest method testIlikeRendering.
@Test
public void testIlikeRendering() {
SessionFactory sf = new Configuration().addAnnotatedClass(IrrelevantEntity.class).setProperty(AvailableSettings.DIALECT, IlikeSupportingDialect.class.getName()).setProperty(Environment.HBM2DDL_AUTO, "create-drop").buildSessionFactory();
try {
final Criteria criteria = sf.openSession().createCriteria(IrrelevantEntity.class);
final CriteriaQueryTranslator translator = new CriteriaQueryTranslator((SessionFactoryImplementor) sf, (CriteriaImpl) criteria, IrrelevantEntity.class.getName(), "a");
final Criterion ilikeExpression = Restrictions.ilike("name", "abc");
final String ilikeExpressionSqlFragment = ilikeExpression.toSqlString(criteria, translator);
assertEquals("a.name insensitiveLike ?", ilikeExpressionSqlFragment);
} finally {
sf.close();
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class CriterionTest method testIlikeMimicing.
@Test
public void testIlikeMimicing() {
SessionFactory sf = new Configuration().addAnnotatedClass(IrrelevantEntity.class).setProperty(AvailableSettings.DIALECT, NonIlikeSupportingDialect.class.getName()).setProperty(Environment.HBM2DDL_AUTO, "create-drop").buildSessionFactory();
try {
final Criteria criteria = sf.openSession().createCriteria(IrrelevantEntity.class);
final CriteriaQueryTranslator translator = new CriteriaQueryTranslator((SessionFactoryImplementor) sf, (CriteriaImpl) criteria, IrrelevantEntity.class.getName(), "a");
final Criterion ilikeExpression = Restrictions.ilike("name", "abc");
final String ilikeExpressionSqlFragment = ilikeExpression.toSqlString(criteria, translator);
assertEquals("lowLowLow(a.name) like ?", ilikeExpressionSqlFragment);
} finally {
sf.close();
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class UserTypeMappingTest method setup.
@Before
public void setup() {
cfg = new Configuration();
Properties p = new Properties();
p.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
p.put("hibernate.connection.driver_class", "org.h2.Driver");
p.put("hibernate.connection.url", "jdbc:h2:mem:");
p.put("hibernate.connection.username", "sa");
p.put("hibernate.connection.password", "");
cfg.setProperties(p);
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(cfg.getProperties());
}
Aggregations