List of usage examples for org.hibernate.id PersistentIdentifierGenerator CATALOG
String CATALOG
To view the source code for org.hibernate.id PersistentIdentifierGenerator CATALOG.
Click Source Link
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
@SuppressWarnings("unchecked") protected void bindSimpleId(GrailsDomainClassProperty identifier, RootClass entity, Mappings mappings, Identity mappedId, String sessionFactoryBeanName) { Mapping mapping = getMapping(identifier.getDomainClass()); boolean useSequence = mapping != null && mapping.isTablePerConcreteClass(); // create the id value SimpleValue id = new SimpleValue(mappings, entity.getTable()); // set identifier on entity Properties params = new Properties(); entity.setIdentifier(id);//ww w . j a v a2s.c om if (mappedId == null) { // configure generator strategy id.setIdentifierGeneratorStrategy(useSequence ? "sequence-identity" : "native"); } else { String generator = mappedId.getGenerator(); if ("native".equals(generator) && useSequence) { generator = "sequence-identity"; } id.setIdentifierGeneratorStrategy(generator); params.putAll(mappedId.getParams()); if ("assigned".equals(generator)) { id.setNullValue("undefined"); } } params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); if (mappings.getSchemaName() != null) { params.setProperty(PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName()); } if (mappings.getCatalogName() != null) { params.setProperty(PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName()); } id.setIdentifierGeneratorProperties(params); // bind value bindSimpleValue(identifier, null, id, EMPTY_PATH, mappings, sessionFactoryBeanName); // create property Property prop = new Property(); prop.setValue(id); // bind property bindProperty(identifier, prop, mappings); // set identifier property entity.setIdentifierProperty(prop); id.getTable().setIdentifierValue(id); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
@SuppressWarnings("unchecked") private static void bindSimpleId(GrailsDomainClassProperty identifier, RootClass entity, Mappings mappings, Identity mappedId, String sessionFactoryBeanName) { // create the id value SimpleValue id = new SimpleValue(mappings, entity.getTable()); // set identifier on entity Properties params = new Properties(); entity.setIdentifier(id);/* www. j a v a2 s .c o m*/ if (mappedId != null) { id.setIdentifierGeneratorStrategy(mappedId.getGenerator()); params.putAll(mappedId.getParams()); if ("assigned".equals(mappedId.getGenerator())) { id.setNullValue("undefined"); } } else { // configure generator strategy id.setIdentifierGeneratorStrategy("native"); } params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); if (mappings.getSchemaName() != null) { params.setProperty(PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName()); } if (mappings.getCatalogName() != null) { params.setProperty(PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName()); } id.setIdentifierGeneratorProperties(params); // bind value bindSimpleValue(identifier, null, id, EMPTY_PATH, mappings, sessionFactoryBeanName); // create property Property prop = new Property(); prop.setValue(id); // bind property bindProperty(identifier, prop, mappings); // set identifier property entity.setIdentifierProperty(prop); id.getTable().setIdentifierValue(id); }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
@SuppressWarnings("unchecked") protected void bindSimpleId(PersistentProperty identifier, RootClass entity, Mappings mappings, Identity mappedId, String sessionFactoryBeanName) { Mapping mapping = getMapping(identifier.getOwner()); boolean useSequence = mapping != null && mapping.isTablePerConcreteClass(); // create the id value SimpleValue id = new SimpleValue(mappings, entity.getTable()); // set identifier on entity Properties params = new Properties(); entity.setIdentifier(id);/*ww w. j a va 2s . c o m*/ if (mappedId == null) { // configure generator strategy id.setIdentifierGeneratorStrategy(useSequence ? "sequence-identity" : "native"); } else { String generator = mappedId.getGenerator(); if ("native".equals(generator) && useSequence) { generator = "sequence-identity"; } id.setIdentifierGeneratorStrategy(generator); params.putAll(mappedId.getParams()); if ("assigned".equals(generator)) { id.setNullValue("undefined"); } } params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); if (mappings.getSchemaName() != null) { params.setProperty(PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName()); } if (mappings.getCatalogName() != null) { params.setProperty(PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName()); } id.setIdentifierGeneratorProperties(params); // bind value bindSimpleValue(identifier, null, id, EMPTY_PATH, mappings, sessionFactoryBeanName); // create property Property prop = new Property(); prop.setValue(id); // bind property bindProperty(identifier, prop, mappings); // set identifier property entity.setIdentifierProperty(prop); id.getTable().setIdentifierValue(id); }
From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
@SuppressWarnings("unchecked") protected void bindSimpleId(PersistentProperty identifier, RootClass entity, InFlightMetadataCollector mappings, Identity mappedId, String sessionFactoryBeanName) { Mapping mapping = getMapping(identifier.getOwner()); boolean useSequence = mapping != null && mapping.isTablePerConcreteClass(); // create the id value SimpleValue id = new SimpleValue(mappings, entity.getTable()); // set identifier on entity Properties params = new Properties(); entity.setIdentifier(id);//from w ww .j av a 2s . com if (mappedId == null) { // configure generator strategy id.setIdentifierGeneratorStrategy(useSequence ? "sequence-identity" : "native"); } else { String generator = mappedId.getGenerator(); if ("native".equals(generator) && useSequence) { generator = "sequence-identity"; } id.setIdentifierGeneratorStrategy(generator); params.putAll(mappedId.getParams()); if (params.containsKey(SEQUENCE_KEY)) { params.put(SequenceStyleGenerator.SEQUENCE_PARAM, params.getProperty(SEQUENCE_KEY)); } if ("assigned".equals(generator)) { id.setNullValue("undefined"); } } String schemaName = getSchemaName(mappings); String catalogName = getCatalogName(mappings); params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, this.metadataBuildingContext.getObjectNameNormalizer()); if (schemaName != null) { params.setProperty(PersistentIdentifierGenerator.SCHEMA, schemaName); } if (catalogName != null) { params.setProperty(PersistentIdentifierGenerator.CATALOG, catalogName); } id.setIdentifierGeneratorProperties(params); // bind value bindSimpleValue(identifier, null, id, EMPTY_PATH, mappings, sessionFactoryBeanName); // create property Property prop = new Property(); prop.setValue(id); // bind property bindProperty(identifier, prop, mappings); // set identifier property entity.setIdentifierProperty(prop); id.getTable().setIdentifierValue(id); }