use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class LoadingSmokeTests method testBasicLoad.
@Test
public void testBasicLoad(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final BasicEntity loaded = session.byId(BasicEntity.class).getReference(1);
assertThat(loaded, notNullValue());
assertThat(Hibernate.isInitialized(loaded), is(false));
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class LoadingSmokeTests method testBasicGet.
@Test
public void testBasicGet(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final BasicEntity gotten = session.byId(BasicEntity.class).load(1);
assertThat(gotten, notNullValue());
assertThat(Hibernate.isInitialized(gotten), is(true));
assertThat(gotten.getId(), is(1));
assertThat(gotten.getData(), is("first"));
final AbstractEntityPersister entityDescriptor = (AbstractEntityPersister) session.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(BasicEntity.class);
final SingleIdEntityLoader singleIdEntityLoader = entityDescriptor.getSingleIdEntityLoader();
assertThat(singleIdEntityLoader, instanceOf(SingleIdEntityLoaderStandardImpl.class));
assertThat(((SingleIdEntityLoaderStandardImpl) singleIdEntityLoader).getNonReusablePlansGenerated().get(), is(0));
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class HqlUpdateExecutionTests method testSimpleRestrictedUpdateWithData.
@Test
public void testSimpleRestrictedUpdateWithData(SessionFactoryScope scope) {
scope.inTransaction(session -> {
session.save(new BasicEntity(1, "abc"));
session.save(new BasicEntity(2, "def"));
});
scope.inTransaction(session -> {
final int rows = session.createQuery("update BasicEntity set data = :val where data = :filter").setParameter("val", "xyz").setParameter("filter", "abc").executeUpdate();
assertThat(rows, is(1));
});
scope.inTransaction(session -> {
final BasicEntity basicEntity = session.get(BasicEntity.class, 1);
assertThat(basicEntity.getData(), is("xyz"));
final BasicEntity basicEntity2 = session.get(BasicEntity.class, 2);
assertThat(basicEntity2.getData(), is("def"));
});
scope.inTransaction(session -> {
final int rows = session.createQuery("delete BasicEntity").executeUpdate();
assertThat(rows, is(2));
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class MultiIdEntityLoadTests method prepareTestData.
@BeforeEach
public void prepareTestData(SessionFactoryScope scope) {
scope.inTransaction(session -> {
final BasicEntity first = new BasicEntity(1, "first");
final BasicEntity second = new BasicEntity(2, "second");
final BasicEntity third = new BasicEntity(3, "third");
session.save(first);
session.save(second);
session.save(third);
session.save(new EntityWithAggregateId(new EntityWithAggregateId.Key("abc", "def"), "ghi"));
session.save(new EntityWithAggregateId(new EntityWithAggregateId.Key("123", "456"), "789"));
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class ILikeCriteriaTest method prepareData.
@BeforeEach
public void prepareData(SessionFactoryScope scope) {
scope.inTransaction(em -> {
BasicEntity be1 = new BasicEntity(1, "Product_one");
em.persist(be1);
BasicEntity be2 = new BasicEntity(2, "proDUct two");
em.persist(be2);
BasicEntity be3 = new BasicEntity(3, "Product three");
em.persist(be3);
BasicEntity be4 = new BasicEntity(4, "pROducT four");
em.persist(be4);
BasicEntity be5 = new BasicEntity(5, "Product five");
em.persist(be5);
BasicEntity be6 = new BasicEntity(6, "Prodact six");
em.persist(be6);
BasicEntity be7 = new BasicEntity(7, "prodACt seven");
em.persist(be7);
BasicEntity be8 = new BasicEntity(8, "Prod_act eight");
em.persist(be8);
BasicEntity be9 = new BasicEntity(9, "prod_ACt nine");
em.persist(be9);
});
}
Aggregations