Search in sources :

Example 1 with BasicCollectionPersister

use of org.hibernate.persister.collection.BasicCollectionPersister in project hibernate-orm by hibernate.

the class ElementCollectionSortingTest method checkSQLOrderBy.

private void checkSQLOrderBy(Session session, String entityName, String propertyName, String order) {
    String roleName = entityName + "." + propertyName;
    String alias = "alias1";
    BasicCollectionPersister collectionPersister = (BasicCollectionPersister) session.getSessionFactory().getCollectionMetadata(roleName);
    Assert.assertTrue(collectionPersister.hasOrdering());
    Assert.assertEquals(alias + "." + propertyName + " " + order, collectionPersister.getSQLOrderByString(alias));
}
Also used : BasicCollectionPersister(org.hibernate.persister.collection.BasicCollectionPersister)

Example 2 with BasicCollectionPersister

use of org.hibernate.persister.collection.BasicCollectionPersister in project hibernate-orm by hibernate.

the class Ejb3XmlTest method testMapXMLSupport.

@Test
@SuppressWarnings("unchecked")
public void testMapXMLSupport() throws Exception {
    Session s = openSession();
    SessionFactory sf = s.getSessionFactory();
    Transaction tx = s.beginTransaction();
    // Verify that we can persist an object with a couple Map mappings
    VicePresident vpSales = new VicePresident();
    vpSales.name = "Dwight";
    Company company = new Company();
    company.conferenceRoomExtensions.put("8932", "x1234");
    company.organization.put("sales", vpSales);
    s.persist(company);
    s.flush();
    s.clear();
    // For the element-collection, check that the orm.xml entries are honored.
    // This includes: map-key-column/column/collection-table/join-column
    BasicCollectionPersister confRoomMeta = (BasicCollectionPersister) sf.getCollectionMetadata(Company.class.getName() + ".conferenceRoomExtensions");
    assertEquals("company_id", confRoomMeta.getKeyColumnNames()[0]);
    assertEquals("phone_extension", confRoomMeta.getElementColumnNames()[0]);
    assertEquals("room_number", confRoomMeta.getIndexColumnNames()[0]);
    assertEquals("phone_extension_lookup", confRoomMeta.getTableName());
    tx.rollback();
    s.close();
}
Also used : SessionFactory(org.hibernate.SessionFactory) BasicCollectionPersister(org.hibernate.persister.collection.BasicCollectionPersister) Transaction(org.hibernate.Transaction) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

BasicCollectionPersister (org.hibernate.persister.collection.BasicCollectionPersister)2 Session (org.hibernate.Session)1 SessionFactory (org.hibernate.SessionFactory)1 Transaction (org.hibernate.Transaction)1 Test (org.junit.Test)1