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 ) ); }
@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(); }
/** {@inheritDoc} **/ public CollectionMetadata getCollectionMetadata(String roleName) { return delegate.getCollectionMetadata(roleName); }
/** {@inheritDoc} **/ public CollectionMetadata getCollectionMetadata(String roleName) { return delegate.getCollectionMetadata(roleName); }
@Override public CollectionMetadata getCollectionMetadata(String roleName) { return delegate.getCollectionMetadata(roleName); }
@Deprecated @Override public CollectionMetadata getCollectionMetadata(String roleName) { return delegate.getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getSessionFactory().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getImpl().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getSessionFactory().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getImpl().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getImpl().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) { return getCurrentSessionFactory().getCollectionMetadata(roleName); }
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { return getImpl().getCollectionMetadata(roleName); }
@Override protected void initDao() throws Exception { super.initDao(); AbstractCollectionPersister persister = (AbstractCollectionPersister) getSessionFactory().getCollectionMetadata(getRole()); indexColumn = persister.getIndexColumnNames()[0]; }
if (persistentCollection.wasInitialized()) { CollectionMetadata collectionMetadata = sessionFactory.getCollectionMetadata(persistentCollection.getRole()); Class<?> elementClass = collectionMetadata.getElementType().getReturnedClass(); if (elementClass.isAssignableFrom(object.getClass())) {
private CollectionType buildCollectionType(SessionFactory sessionFactory, Class<?> collectionClass, String role) { CollectionMetadata cm = sessionFactory.getCollectionMetadata(role); // FIXME buildCollectionType if (null == cm) return null; org.hibernate.type.Type type = cm.getElementType(); EntityType elementType = null; if (type.isEntityType()) { elementType = (EntityType) entityTypes.get(type.getName()); if (null == elementType) elementType = buildEntityType(sessionFactory, type.getName()); } else { elementType = new EntityType(type.getReturnedClass()); } CollectionType collectionType = new CollectionType(); collectionType.setElementType(elementType); collectionType.setArray(cm.isArray()); collectionType.setCollectionClass(collectionClass); if (!collectionTypes.containsKey(collectionType.getName())) { collectionTypes.put(collectionType.getName(), collectionType); } return collectionType; }