protected void createInstances()

in grails-datastore-gorm-hibernate/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java [3500:3559]


        protected void createInstances() {

            if (initialized) {
                return;
            }

            initialized = true;

            SET = new CollectionType(Set.class, binder) {
                @Override
                public Collection create(ToMany property, PersistentClass owner,
                                         String path, InFlightMetadataCollector mappings, String sessionFactoryBeanName) throws MappingException {
                    org.hibernate.mapping.Set coll = new org.hibernate.mapping.Set(buildingContext, owner);
                    coll.setCollectionTable(owner.getTable());
                    coll.setTypeName(getTypeName(property));
                    binder.bindCollection(property, coll, owner, mappings, path, sessionFactoryBeanName);
                    return coll;
                }
            };
            INSTANCES.put(Set.class, SET);
            INSTANCES.put(SortedSet.class, SET);

            LIST = new CollectionType(List.class, binder) {
                @Override
                public Collection create(ToMany property, PersistentClass owner,
                                         String path, InFlightMetadataCollector mappings, String sessionFactoryBeanName) throws MappingException {
                    org.hibernate.mapping.List coll = new org.hibernate.mapping.List(buildingContext, owner);
                    coll.setCollectionTable(owner.getTable());
                    coll.setTypeName(getTypeName(property));
                    binder.bindCollection(property, coll, owner, mappings, path, sessionFactoryBeanName);
                    return coll;
                }
            };
            INSTANCES.put(List.class, LIST);

            BAG = new CollectionType(java.util.Collection.class, binder) {
                @Override
                public Collection create(ToMany property, PersistentClass owner,
                                         String path, InFlightMetadataCollector mappings, String sessionFactoryBeanName) throws MappingException {
                    Bag coll = new Bag(buildingContext, owner);
                    coll.setCollectionTable(owner.getTable());
                    coll.setTypeName(getTypeName(property));
                    binder.bindCollection(property, coll, owner, mappings, path, sessionFactoryBeanName);
                    return coll;
                }
            };
            INSTANCES.put(java.util.Collection.class, BAG);

            MAP = new CollectionType(Map.class, binder) {
                @Override
                public Collection create(ToMany property, PersistentClass owner,
                                         String path, InFlightMetadataCollector mappings, String sessionFactoryBeanName) throws MappingException {
                    org.hibernate.mapping.Map map = new org.hibernate.mapping.Map(buildingContext, owner);
                    map.setTypeName(getTypeName(property));
                    binder.bindCollection(property, map, owner, mappings, path, sessionFactoryBeanName);
                    return map;
                }
            };
            INSTANCES.put(Map.class, MAP);
        }