List of usage examples for org.hibernate.mapping Property getName
public String getName()
From source file:com.tomitribe.reveng.codegen.FreemarkerObject.java
License:Apache License
public String asParameterList(final Cfg2JavaTool c2j, final Iterator fields, final boolean useGenerics, final ImportContext ic) { final StringBuilder sb = new StringBuilder(); while (fields.hasNext()) { final Property field = (Property) fields.next(); sb.append("final "); sb.append(c2j.getJavaTypeName(field, useGenerics, ic)).append(" ").append(field.getName()); if (fields.hasNext()) { sb.append(", "); }// w ww .ja va 2 s .c om } return sb.toString(); }
From source file:com.tomitribe.reveng.codegen.FreemarkerObject.java
License:Apache License
public String annotate(final BasicPOJOClass pojo, final Object pObj, final Object rootObj, final Object toolObj) { // public String annotate(final Object pojo, final Property p, final // RootClass root, final Cfg2HbmTool tool) { if (BasicPOJOClass.class.isInstance(pojo)) { } else {//from w ww . j a va2 s .c o m // System.out.println(ob.class.getName()); } RootClass root = null; try { root = (RootClass) rootObj; } catch (final Exception e) { // TODO Auto-generated catch block // e.printStackTrace(); return ""; } final Property p = (Property) pObj; final Cfg2HbmTool tool = (Cfg2HbmTool) toolObj; final Table table = root.getTable(); Iterator it = table.getColumnIterator(); Column column = null; Column c; String name; while (it.hasNext()) { c = (Column) it.next(); name = c.getName().replace("_", "").toLowerCase(); if (name.equals(p.getName().toLowerCase())) { column = c; break; } } if (null != column) { System.out.print("FreemarkerObject.annotate: " + table.getName() + " - " + p.getName() + " - "); it = table.getIndexIterator(); org.hibernate.mapping.Index index; while (it.hasNext()) { final Object next = it.next(); if (org.hibernate.mapping.Index.class.isInstance(next)) { index = org.hibernate.mapping.Index.class.cast(next); if (index.containsColumn(column)) { System.out.print(index.getName()); return String.format("\n@Index(name = \"%1$s\", columnNames = {\"%2$s\"})", index.getName().toLowerCase(), column.getName()); } } } System.out.println(); } else { System.out.println("FreemarkerObject.annotate: " + table.getName() + " - " + p.getName() + " - " + p.getNodeName() + " - " + p.getPropertyAccessorName()); } return ""; }
From source file:com.tomitribe.reveng.codegen.FreemarkerObject.java
License:Apache License
public boolean isNotHiddenParameter(final Property property) { // System.out.println("property = " + property.getName()); return !"storestamp".equals(property.getName()); }
From source file:com.wavemaker.runtime.data.hibernate.DataServiceMetaData_Hib.java
License:Open Source License
private void initProperty(String owningClassName, Property p, Map<String, Property> propertiesMap) { this.allProperties.put(owningClassName, p); if (p != null) { this.allPropertyNames.put(owningClassName, p.getName()); propertiesMap.put(p.getName(), p); Value v = p.getValue();/*from ww w . j ava 2s.c o m*/ if (v.getType().isEntityType() || !v.isSimpleValue()) { this.relProperties.put(owningClassName, p); this.relPropertyNames.put(owningClassName, p.getName()); } if (p.getType().isComponentType()) { addComponentProperties(p); } } }
From source file:com.wavemaker.runtime.data.hibernate.DataServiceMetaData_Hib.java
License:Open Source License
@Override public String getIdPropertyName(Class<?> c) { if (!isEntity(c)) { throw new DataServiceRuntimeException(c + " is not an entity"); }/*from ww w . j a v a2 s .c o m*/ RootClass rc = getRootClass(c); Property id = rc.getIdentifierProperty(); return id.getName(); }
From source file:com.xpn.xwiki.store.XWikiHibernateStore.java
License:Open Source License
private boolean isValidCustomMapping(String className, Configuration hibconfig, BaseClass bclass) { PersistentClass mapping = hibconfig.getClassMapping(className); if (mapping == null) { return true; }/*w w w . java 2s . c o m*/ Iterator it = mapping.getPropertyIterator(); while (it.hasNext()) { Property hibprop = (Property) it.next(); String propname = hibprop.getName(); PropertyClass propclass = (PropertyClass) bclass.getField(propname); if (propclass == null) { log.warn("Mapping contains invalid field name " + propname); return false; } boolean result = isValidColumnType(hibprop.getValue().getType().getName(), propclass.getClassName()); if (result == false) { log.warn("Mapping contains invalid type in field " + propname); return false; } } return true; }
From source file:com.xpn.xwiki.store.XWikiHibernateStore.java
License:Open Source License
public List<String> getCustomMappingPropertyList(BaseClass bclass) { List<String> list = new ArrayList<String>(); Configuration hibconfig;/*from ww w . j a v a 2s. co m*/ if (bclass.hasExternalCustomMapping()) { hibconfig = makeMapping(bclass.getName(), bclass.getCustomMapping()); } else { hibconfig = getConfiguration(); } PersistentClass mapping = hibconfig.getClassMapping(bclass.getName()); if (mapping == null) { return null; } Iterator it = mapping.getPropertyIterator(); while (it.hasNext()) { Property hibprop = (Property) it.next(); String propname = hibprop.getName(); list.add(propname); } return list; }
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 www. j a v a 2s . c om*/ } } 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 w w w. ja v a 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 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. */// w w w . ja v a 2s. 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; }