Search in sources :

Example 1 with TextHolder

use of org.hibernate.test.sql.hand.TextHolder in project hibernate-orm by hibernate.

the class CustomSQLTestSupport method testTextProperty.

@Test
public void testTextProperty() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    String description = buildLongString(15000, 'a');
    TextHolder holder = new TextHolder(description);
    s.save(holder);
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    holder = (TextHolder) s.get(TextHolder.class, holder.getId());
    assertEquals(description, holder.getDescription());
    description = buildLongString(15000, 'b');
    holder.setDescription(description);
    s.save(holder);
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    holder = (TextHolder) s.get(TextHolder.class, holder.getId());
    assertEquals(description, holder.getDescription());
    s.delete(holder);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) TextHolder(org.hibernate.test.sql.hand.TextHolder) Session(org.hibernate.Session) Test(org.junit.Test)

Example 2 with TextHolder

use of org.hibernate.test.sql.hand.TextHolder in project hibernate-orm by hibernate.

the class NativeSQLQueriesTest method testTextTypeInSQLQuery.

@SkipForDialect(value = AbstractHANADialect.class, comment = "On HANA, this returns an clob for the text column which doesn't get mapped to a String")
@Test
public void testTextTypeInSQLQuery() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    String description = buildLongString(15000, 'a');
    TextHolder holder = new TextHolder(description);
    s.persist(holder);
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    String descriptionRead = (String) s.createSQLQuery(getDescriptionsSQL()).uniqueResult();
    assertEquals(description, descriptionRead);
    s.delete(holder);
    t.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) TextHolder(org.hibernate.test.sql.hand.TextHolder) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Aggregations

Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 TextHolder (org.hibernate.test.sql.hand.TextHolder)2 Test (org.junit.Test)2 SkipForDialect (org.hibernate.testing.SkipForDialect)1