List of usage examples for org.hibernate.mapping Property getColumnIterator
public Iterator getColumnIterator()
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticmi.HbMappedClass.java
License:Open Source License
/** * Get a {@link Column} for a {@link Property} * //from w ww .ja va 2s . c o m * @param property * @return the {@link Column}; */ private Column getColumn(Property property) { if (property == null || !property.getColumnIterator().hasNext()) { return null; } return (Column) property.getColumnIterator().next(); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.xmi.exporter.ecore.HbMappedClass.java
License:Open Source License
/** * Get a {@link Column} for a {@link Property} * /*from w w w . j av a2 s.c o m*/ * @param property * @return the {@link Column}; */ private Column getColumn(Property property) { if (property == null || !property.getColumnIterator().hasNext()) { return null; } return (Column) property.getColumnIterator().next(); }
From source file:edu.wustl.common.util.dbManager.HibernateMetaData.java
License:BSD License
public static String getColumnName(Class classObj, String attributeName) { //Logger.out.debug("classObj, String attributeName "+classObj+" "+attributeName); Iterator it = cfg.getClassMapping(classObj.getName()).getPropertyClosureIterator(); while (it.hasNext()) { Property property = (Property) it.next(); //Logger.out.debug("property.getName() "+property.getName()); //System.out.println(); //System.out.print("property.getName() "+property.getName()+" "); if (property != null && property.getName().equals(attributeName)) { //System.out.println("property.getColumnSpan() "+property.getColumnSpan()); Iterator colIt = property.getColumnIterator(); while (colIt.hasNext()) { Column col = (Column) colIt.next(); //System.out.println("col "+col.getName()); return col.getName(); }/*from w w w . jav a 2 s .c o m*/ } } Property property = cfg.getClassMapping(classObj.getName()).getIdentifierProperty(); //Logger.out.debug("property.getName() "+property.getName()); if (property.getName().equals(attributeName)) { Iterator colIt = property.getColumnIterator();//y("id").getColumnIterator(); while (colIt.hasNext()) { Column col = (Column) colIt.next(); return col.getName(); //System.out.println(col.getName()); } } return ""; }
From source file:edu.wustl.common.util.dbManager.HibernateMetaData.java
License:BSD License
/** * @param classObj Name of the class.//from ww w.jav a2s . c o m * @param attributeName Name of the attribute. * @return The width of the column. Returns width of the column or zero. */ public static int getColumnWidth(Class classObj, String attributeName) { Iterator it = cfg.getClassMapping(classObj.getName()).getPropertyClosureIterator(); while (it.hasNext()) { Property property = (Property) it.next(); if (property != null && property.getName().equals(attributeName)) { Iterator colIt = property.getColumnIterator(); while (colIt.hasNext()) { Column col = (Column) colIt.next(); return col.getLength(); } } } // if attribute is not found than the default width will be 50. return 50; }
From source file:edu.wustl.dao.util.HibernateMetaData.java
License:BSD License
/** * This method will returns the column name associate to given property. * @param iter : holds the property object. * @param attributeName :attribute of the given class * @return returns the Column Name mapped to the attribute. */// ww w .j a va 2 s. co m private static String getColumnName(String attributeName, Iterator<Object> iter) { String columnName = DAOConstants.TAILING_SPACES; Property property = (Property) iter.next(); if (property != null && property.getName().equals(attributeName)) { Iterator<Object> colIt = property.getColumnIterator(); if (colIt.hasNext()) { Column col = (Column) colIt.next(); columnName = col.getName(); } } return columnName; }
From source file:edu.wustl.dao.util.HibernateMetaData.java
License:BSD License
/** *This method will iterate the Identified property file and returns the column name. * @param classObj : Class of the object * @param attributeName :attribute of the given class * @return returns the Column Name mapped to the attribute. *//* w w w . j av a2s .c om*/ private static String getColumName(Class classObj, String attributeName) { String columnName = DAOConstants.TAILING_SPACES; Property property = cfg.getClassMapping(classObj.getName()).getIdentifierProperty(); if (property.getName().equals(attributeName)) { Iterator<Object> colIt = property.getColumnIterator();//y("id").getColumnIterator(); if (colIt.hasNext()) { Column col = (Column) colIt.next(); columnName = col.getName(); } } return columnName; }
From source file:edu.wustl.dao.util.HibernateMetaData.java
License:BSD License
/** * This method will be called to obtained column width of attribute field of given class. * @param classObj Name of the class./* ww w . j a va 2 s.c o m*/ * @param attributeName Name of the attribute. * @return The width of the column. Returns width of the column or zero. */ public static int getColumnWidth(Class classObj, String attributeName) { Iterator iterator = cfg.getClassMapping(classObj.getName()).getPropertyClosureIterator(); int colLength = 50; while (iterator.hasNext()) { Property property = (Property) iterator.next(); if (property != null && property.getName().equals(attributeName)) { Iterator colIt = property.getColumnIterator(); while (colIt.hasNext()) { Column col = (Column) colIt.next(); colLength = col.getLength(); } } } // if attribute is not found than the default width will be 50. return colLength; }
From source file:gov.nih.nci.caarray.validation.UniqueConstraintValidator.java
License:BSD License
/** * {@inheritDoc}//w ww . j a v a2 s . c o m */ public void apply(PersistentClass pc) { if (this.uniqueConstraint.generateDDLConstraint()) { List<Column> columns = new ArrayList<Column>(); for (UniqueConstraintField field : uniqueConstraint.fields()) { Property prop = pc.getProperty(field.name()); CollectionUtils.addAll(columns, prop.getColumnIterator()); } pc.getTable().createUniqueKey(columns); } }
From source file:gov.nih.nci.protexpress.data.validator.UniqueConstraintValidator.java
License:BSD License
/** * {@inheritDoc}//from ww w . ja v a2 s. c om */ @SuppressWarnings("unchecked") public void apply(Property property) { if (!property.isComposite()) { // currently not supporting composite columns Iterator<Column> iter = property.getColumnIterator(); while (iter.hasNext()) { iter.next().setUnique(true); } } }
From source file:it.eng.qbe.model.structure.builder.hibernate.HibernateModelStructureBuilder.java
License:Mozilla Public License
public List addNormalFields(IModelEntity dataMartEntity) { ClassMetadata classMetadata;/* w ww. jav a2 s . c om*/ PersistentClass classMapping; String[] propertyNames; Property property; Type propertyType; classMetadata = getDataSource().getHibernateSessionFactory().getClassMetadata(dataMartEntity.getType()); classMapping = getDataSource().getHibernateConfiguration().getClassMapping(dataMartEntity.getType()); propertyNames = classMetadata.getPropertyNames(); List subEntities = new ArrayList(); String propertyName = null; for (int i = 0; i < propertyNames.length; i++) { property = classMapping.getProperty(propertyNames[i]); // TEST if they are the same: if so use the first invocation propertyType = property.getType(); Iterator columnIterator = property.getColumnIterator(); Column column; if (propertyType instanceof ManyToOneType) { // chiave esterna ManyToOneType manyToOnePropertyType = (ManyToOneType) propertyType; String entityType = manyToOnePropertyType.getAssociatedEntityName(); String columnName = null; if (columnIterator.hasNext()) { column = (Column) columnIterator.next(); columnName = column.getName(); // ???? } propertyName = propertyNames[i]; //String entityName = getEntityNameFromEntityType(entityType); String entityName = propertyName; IModelEntity subentity = new ModelEntity(entityName, null, columnName, entityType, dataMartEntity.getStructure()); subEntities.add(subentity); } else if (propertyType instanceof CollectionType) { // chiave interna } else { // normal field propertyName = propertyNames[i]; String type = propertyType.getName(); int scale = 0; int precision = 0; if (columnIterator.hasNext()) { column = (Column) columnIterator.next(); scale = column.getScale(); precision = column.getPrecision(); } IModelField datamartField = dataMartEntity.addNormalField(propertyName); datamartField.setType(type); datamartField.setPrecision(precision); datamartField.setLength(scale); propertiesInitializer.addProperties(datamartField); } } return subEntities; }