List of usage examples for org.hibernate.mapping Property getName
public String getName()
From source file:com.clueride.rest.MemberWebService.java
License:Apache License
private void dumpEntities() { Metadata metadata = MetadataExtractorIntegrator.INSTANCE.getMetadata(); for (PersistentClass persistentClass : metadata.getEntityBindings()) { Table table = persistentClass.getTable(); LOGGER.info(String.format("Entity: {} is mapped to table: {}", persistentClass.getClassName(), table.getName()));//w w w . j a v a2 s. c om for (Iterator propertyIterator = persistentClass.getPropertyIterator(); propertyIterator.hasNext();) { Property property = (Property) propertyIterator.next(); for (Iterator columnIterator = property.getColumnIterator(); columnIterator.hasNext();) { Column column = (Column) columnIterator.next(); LOGGER.info(String.format("Property: {} is mapped on table column: {} of type: {}", property.getName(), column.getName(), column.getSqlType())); } } } }
From source file:com.github.shyiko.rook.target.hibernate4.cache.PrimaryKey.java
License:Apache License
private PrimaryKey(KeyValue keyValue, Table table, Map<String, Integer> columnIndexByNameMap) { KeyColumn[] positionWithinRow = new KeyColumn[keyValue.getColumnSpan()]; int index = 0; if (keyValue instanceof Component) { Iterator propertyIterator = ((Component) keyValue).getPropertyIterator(); while (propertyIterator.hasNext()) { Property property = (Property) propertyIterator.next(); String columnName = ((Column) property.getColumnIterator().next()).getName(); positionWithinRow[index++] = new KeyColumn(property.getName(), columnIndexByNameMap.get(columnName)); }/*www .j a v a 2s . co m*/ } else { Iterator columnIterator = keyValue.getColumnIterator(); while (columnIterator.hasNext()) { String columnName = ((Column) columnIterator.next()).getName(); positionWithinRow[index++] = new KeyColumn(columnName, columnIndexByNameMap.get(columnName)); } } if (positionWithinRow.length == 0) { throw new IllegalStateException("Unable to determine PK for " + table.getName()); } this.positionWithinRow = positionWithinRow; }
From source file:com.github.shyiko.rook.target.hibernate4.fulltextindex.PrimaryKey.java
License:Apache License
public PrimaryKey(PersistentClass persistentClass) { this.entityClass = persistentClass.getMappedClass(); KeyValue keyValue = persistentClass.getKey(); Table table = persistentClass.getTable(); Map<String, Integer> columnIndexByNameMap = getColumnIndexByNameMap(table); KeyColumn[] positionWithinRow = new KeyColumn[keyValue.getColumnSpan()]; int index = 0; if (keyValue instanceof Component) { Iterator propertyIterator = ((Component) keyValue).getPropertyIterator(); while (propertyIterator.hasNext()) { Property property = (Property) propertyIterator.next(); String columnName = ((Column) property.getColumnIterator().next()).getName(); positionWithinRow[index++] = new KeyColumn(property.getName(), columnIndexByNameMap.get(columnName)); }//w w w .j a v a 2 s . c o m } else { Iterator columnIterator = keyValue.getColumnIterator(); while (columnIterator.hasNext()) { String columnName = ((Column) columnIterator.next()).getName(); positionWithinRow[index++] = new KeyColumn(columnName, columnIndexByNameMap.get(columnName)); } } if (positionWithinRow.length == 0) { throw new IllegalStateException("Unable to determine PK for " + table.getName()); } Property identifierProperty = persistentClass.getIdentifierProperty(); this.getter = identifierProperty.getGetter(this.entityClass); this.positionWithinRow = positionWithinRow; }
From source file:com.googlecode.hibernate.audit.listener.AuditSessionFactoryObserver.java
License:Open Source License
private AuditType initializeEntityAuditType(Session session, String entityName, boolean initializeProperties) { PersistentClass classMapping = auditConfiguration.getMetadata().getEntityBinding(entityName); String auditTypeClassName = auditConfiguration.getExtensionManager().getAuditableInformationProvider() .getAuditTypeClassName(auditConfiguration.getMetadata(), entityName); AuditType auditType = HibernateAudit.getAuditType(session, auditTypeClassName); if (auditType == null) { auditType = new AuditType(); auditType.setClassName(auditTypeClassName); auditType.setLabel(entityName);// ww w. j ava2 s. co m auditType.setType(AuditType.ENTITY_TYPE); session.save(auditType); updateMetaModel(session); } if (initializeProperties) { Property identifierProperty = classMapping.getIdentifierProperty(); if (identifierProperty != null) { initializeAuditField(session, auditTypeClassName, auditType, identifierProperty.getName(), identifierProperty.getType()); } for (Iterator propertyIterator = classMapping.getPropertyClosureIterator(); propertyIterator .hasNext();) { Property property = (Property) propertyIterator.next(); initializeAuditField(session, auditTypeClassName, auditType, property.getName(), property.getType()); } } return auditType; }
From source file:com.oy.shared.lm.ext.HBMCtoGRAPH.java
License:Open Source License
private void processProperties(Iterator iter, GraphNode current) { List attrs = new ArrayList(); while (iter.hasNext()) { Property prop = (Property) iter.next(); Value val = prop.getValue(); // one-to-one/many-to-one if (val instanceof ToOne || val instanceof Component) { addToOneProp(prop, current); continue; }//from w w w .j a v a 2 s . co m // collections if (val instanceof Collection) { addCollectionProp(prop, current); continue; } // simple value if (options.detailed) { if (val instanceof SimpleValue) { Attribute attr = addSimpleProp((SimpleValue) prop.getValue(), prop.getName()); attrs.add(attr); continue; } } } String label = renderAttributes((Attribute[]) attrs.toArray(new Attribute[] {})); current.getInfo().setCaption(label); }
From source file:com.oy.shared.lm.ext.HBMCtoGRAPH.java
License:Open Source License
private void addToOneProp(Property prop, GraphNode current) { Value val = prop.getValue(); String clazz = null;/* w ww.j av a2s .c o m*/ boolean owned = false; if (val instanceof Component) { clazz = ((Component) prop.getValue()).getComponentClassName(); owned = true; } else { if (val instanceof ToOne) { clazz = prop.getType().getName(); owned = ((ToOne) val).isCascadeDeleteEnabled(); } else { throw new RuntimeException("Expected ToOne or Component."); } } GraphNode child = getOrCreateNode(clazz); // relation GraphEdge edge = graph.addEdge(current, child); edge.getInfo().setCaption(prop.getName()); edge.getInfo().setLineColor(colors[1]); // multiplicity if (val instanceof ManyToOne) { edge.getInfo().setTailCaption("0..n"); edge.getInfo().setHeadCaption(""); } else { edge.getInfo().setHeadCaption(""); } // ownership vs. association if (owned) { edge.getInfo().setArrowTailDiamond(); } else { edge.getInfo().setModeDashed(); } // component attributes if (val instanceof Component) { processProperties(((Component) prop.getValue()).getPropertyIterator(), child); } }
From source file:com.oy.shared.lm.ext.HBMCtoGRAPH.java
License:Open Source License
private void addCollectionProp(Property prop, GraphNode current) { Value val = prop.getValue(); if (!(val instanceof Collection)) { throw new RuntimeException("Expected Collection."); }/*from w ww . j a v a2 s .c om*/ Collection col = (Collection) prop.getValue(); Value elem = col.getElement(); if (elem instanceof OneToMany) { String clazz = col.getElement().getType().getName(); GraphNode child = getOrCreateNode(clazz); // relation GraphEdge edge = graph.addEdge(current, child); edge.getInfo().setCaption(prop.getName()); edge.getInfo().setLineColor(colors[2]); edge.getInfo().setHeadCaption("0..n"); edge.getInfo().setArrowTailDiamond(); return; } if (elem instanceof ManyToOne) { String clazz = col.getElement().getType().getName(); GraphNode child = getOrCreateNode(clazz); // relation GraphEdge edge = graph.addEdge(current, child); edge.getInfo().setCaption(prop.getName()); edge.getInfo().setLineColor(colors[2]); edge.getInfo().setArrowTailDiamond(); edge.getInfo().setHeadCaption("0..n"); edge.getInfo().setTailCaption("0..n"); return; } if (elem instanceof Component) { String clazz = prop.getName(); GraphNode child = getOrCreateNode("<<" + col.getClass().getName() + ">>\n" + clazz); // relation GraphEdge edge = graph.addEdge(current, child); edge.getInfo().setLineColor(colors[1]); edge.getInfo().setArrowTailDiamond(); processProperties(((Component) elem).getPropertyIterator(), child); return; } if (elem instanceof SimpleValue) { String clazz = prop.getName(); GraphNode child = getOrCreateNode("<<" + col.getClass().getName() + ">>\n" + clazz); // relation GraphEdge edge = graph.addEdge(current, child); edge.getInfo().setLineColor(colors[1]); edge.getInfo().setArrowTailDiamond(); List attrs = new ArrayList(); Attribute attr = addSimpleProp((SimpleValue) elem, null); attrs.add(attr); String label = renderAttributes((Attribute[]) attrs.toArray(new Attribute[] {})); child.getInfo().setCaption(label); return; } throw new RuntimeException("Unexpected collection element."); }
From source file:com.siemens.scr.avt.ad.query.common.DicomMappingDictionaryLoadingStrategy.java
License:Open Source License
private void loadProperty(DicomMappingDictionary dict, Property prop, Table table, String classPrefix) { String key = classPrefix + "." + prop.getName(); Type type = prop.getType();/*w w w . j a v a 2s . c o m*/ String tableName = table.getSchema() + "." + table.getName(); if (type.isAssociationType() || type.isCollectionType()) { // do nothing } else if (type.isComponentType()) { Component component = (Component) prop.getValue(); Iterator<Property> it = component.getPropertyIterator(); while (it.hasNext()) { Property subProp = it.next(); loadProperty(dict, subProp, table, component.getRoleName()); } } else { int sqltype = sqlTypes(type); assert prop.getColumnSpan() == 1; Iterator<Column> it = prop.getColumnIterator(); String column = it.next().getName(); dict.addMappingEntry(key, tableName, column, sqltype); loadTag(dict, prop, key); loadDicomHeaderMetadata(dict, tableName, column, prop); } }
From source file:com.tomitribe.reveng.codegen.FreemarkerObject.java
License:Apache License
public String generateBasicAnnotation(final POJOClass pojo, final Property p) { final String s = trim(pojo.generateBasicAnnotation(p)); if ("id".equals(p.getName())) { }/*from w w w .j a v a 2s .co m*/ return s; }
From source file:com.tomitribe.reveng.codegen.FreemarkerObject.java
License:Apache License
public String generateAnnColumnAnnotation(final POJOClass pojo, final Property p) { String s = pojo.generateAnnColumnAnnotation(p); // if (!p.isComposite() && p.getColumnSpan() == 1) { // Selectable selectable = (Selectable) p.getColumnIterator().next(); ////from w w w . j a v a 2 s . c om // if (!selectable.isFormula()) { // Column column = (Column) selectable; // // if ("body_size_x".equals(column.getName())) { // log.info(column.toString()); // log.info(column.getLength()); // log.info(column.getSqlTypeCode()); // } // // // } // } s = trim(s); if ("data".equals(p.getName()) && !s.contains(", length=")) { s = s.substring(0, (s.lastIndexOf(')'))); // s += ", length=Integer.MAX_VALUE)"; s += ")"; } else if ("id".equals(p.getName())) { } else { s = ("\n" + s); } if ("storestamp".equals(p.getName())) { s = s.replace(", length=29", ", insertable = false, updatable = false, columnDefinition=\"timestamp not null default current_timestamp\""); } // Never have this on a Column - always in annotation @UniqueConstraint s = s.replace(", unique=true", ""); // if (s.indexOf("\"version\"") > -1) { // s = s.replace("\"version\"", "\"`version`\""); // } // // if (s.indexOf("\"valid\"") > -1) { // s = s.replace("\"valid\"", "\"`valid`\""); // } // // if (s.indexOf("\"type\"") > -1) { // s = s.replace("\"type\"", "\"`type`\""); // } // System.out.println("Column: " + s); return s; }