List of usage examples for org.hibernate.mapping Property getName
public String getName()
From source file:org.zht.framework.service.impl.BaseServiceImpl.java
License:Apache License
private String checkUnique(M m) { // final PersistentClass clazz = factory.getConfiguration().getClassMapping(m.getClass().getName()); if (clazz == null) { throw new ServiceLogicalException("[]???"); }/*from ww w. j a v a 2s .c o m*/ // final Table table = clazz.getTable(); // if(table==null){ // throw new ServiceLogicalException("[]???"); // } @SuppressWarnings("unchecked") final Iterator<Property> iterator = clazz.getPropertyIterator(); if (iterator == null) { throw new ServiceLogicalException( "[]???"); } //MethodAccess access = MethodAccess.get(m.getClass()); while (iterator.hasNext()) { Property property = iterator.next(); if ("id".equals(property.getName())) { continue; } Iterator<?> columnIterator = property.getColumnIterator(); if (columnIterator.hasNext()) { Column column = (Column) columnIterator.next(); if (column.isUnique()) { Object value = (Object) access.invoke(m, "get" + ZStrUtil.toUpCaseFirst(property.getName())); //System.out.println(property.getName()+" "+value); Object id = baseDaoImpl.findIdByUnique(m.getClass(), property.getName(), value); if (id != null && !id.equals(m.getId())) { return ("?[" + value + "]?"); } } } } return null; }
From source file:tools.xor.HibernateType.java
License:Apache License
public void setProperty(HibernateDAS dataAccessService) { if (properties == null) { // populate the properties for this type properties = new HashMap<String, Property>(); Iterator<?> propertyIterator = getPropertyIterator(); while (propertyIterator.hasNext()) { org.hibernate.mapping.Property hibernateProperty = (org.hibernate.mapping.Property) propertyIterator .next();//from w w w.j av a 2 s . c om logger.debug("[" + getName() + "] hibernate property name: " + hibernateProperty.getName() + ", type name: " + hibernateProperty.getType().getReturnedClass()); Type propertyType = dataAccessService.getType(hibernateProperty.getType().getReturnedClass()); HibernateProperty property = new HibernateProperty(hibernateProperty, propertyType, this, dataAccessService.getConfiguration()); property.init(dataAccessService); properties.put(property.getName(), property); } // Components don't have identifiers if (!hibernateType.isComponentType()) { org.hibernate.mapping.Property idProperty = ((PersistentClass) hibernateClass) .getIdentifierProperty(); if (idProperty != null) { logger.debug("Hibernate Identifier attribute name: " + idProperty.getName()); Type propertyType = dataAccessService.getType(idProperty.getType().getReturnedClass()); identifierProperty = new HibernateProperty(idProperty, propertyType, this, dataAccessService.getConfiguration()); properties.put(identifierProperty.getName(), identifierProperty); } org.hibernate.mapping.Property verProperty = ((PersistentClass) hibernateClass).getVersion(); if (verProperty != null) { logger.debug("Hibernate version attribute name: " + verProperty.getName()); Type propertyType = dataAccessService.getType(verProperty.getType().getReturnedClass()); versionProperty = new HibernateProperty(verProperty, propertyType, this, dataAccessService.getConfiguration()); properties.put(versionProperty.getName(), versionProperty); } } } }
From source file:tools.xor.HibernateType.java
License:Apache License
@Override public List<Property> getDeclaredProperties() { List<Property> result = new ArrayList<Property>(); if (!hibernateType.isComponentType()) { Iterator<?> declaredPropertyIterator = ((PersistentClass) hibernateClass).getDeclaredPropertyIterator(); while (declaredPropertyIterator.hasNext()) { org.hibernate.mapping.Property declaredProperty = (org.hibernate.mapping.Property) declaredPropertyIterator .next();/*from ww w . ja v a 2s . co m*/ logger.debug("[" + getName() + "] Hibernate declared property name: " + declaredProperty.getName()); result.add(properties.get(declaredProperty.getName())); } } return result; }