List of usage examples for org.hibernate.mapping Property isBackRef
public boolean isBackRef()
From source file:lucee.runtime.orm.hibernate.tuplizer.AbstractEntityTuplizerImpl.java
License:Open Source License
/** * return accessors //from w w w . j a v a2s .co m * @param mappedProperty * @return */ private PropertyAccessor buildPropertyAccessor(Property mappedProperty) { if (mappedProperty.isBackRef()) { PropertyAccessor ac = mappedProperty.getPropertyAccessor(null); if (ac != null) return ac; } return accessor; }
From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java
License:Open Source License
@Override protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) { initEClass(mappedEntity);//from w w w . j av a 2s .c o m if (TRACER.isEnabled()) { TRACER.trace("Building property getter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } if (mappedProperty.isBackRef()) { return mappedProperty.getGetter(mappedEntity.getMappedClass()); } final CDOPropertyGetter getter; if (mappedProperty == mappedEntity.getIdentifierProperty()) { getter = new CDOIDPropertyGetter(this, mappedProperty.getName()); } else if (mappedProperty.getMetaAttribute("version") != null) { getter = new CDOVersionPropertyGetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) { getter = new CDOResourceIDGetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) { getter = new CDOContainerGetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) { getter = new CDOBranchTimeStampGetter(this, mappedProperty.getName()); } else { EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName()); if (feature instanceof EReference && feature.isMany() && HibernateUtil.getInstance().isCDOResourceContents(feature)) { getter = new CDOManyAttributeGetter(this, mappedProperty.getName()); } else if (feature instanceof EReference && feature.isMany()) { getter = new CDOManyReferenceGetter(this, mappedProperty.getName()); } else if (feature instanceof EReference) { getter = new CDOReferenceGetter(this, mappedProperty.getName()); } else if (feature instanceof EAttribute && feature.isMany()) { getter = new CDOManyAttributeGetter(this, mappedProperty.getName()); } else { getter = new CDOPropertyGetter(this, mappedProperty.getName()); } } HibernateStore hbStore = HibernateStore.getCurrentHibernateStore(); getter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions()); return getter; }
From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java
License:Open Source License
@Override protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) { initEClass(mappedEntity);/*from w ww . jav a 2s . c o m*/ if (TRACER.isEnabled()) { TRACER.trace("Building property setter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } if (mappedProperty.isBackRef()) { return mappedProperty.getSetter(mappedEntity.getMappedClass()); } final CDOPropertySetter setter; if (mappedProperty == mappedEntity.getIdentifierProperty()) { setIdentifierTypeAsAnnotation(mappedProperty); setter = new CDOIDPropertySetter(this, mappedProperty.getName()); } else if (mappedProperty.getMetaAttribute("version") != null) { setter = new CDOVersionPropertySetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) { setter = new CDOResourceIDSetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) { setter = new CDOContainerSetter(this, mappedProperty.getName()); } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) { setter = new CDOBranchTimeStampSetter(this, mappedProperty.getName()); } else { EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName()); if (feature instanceof EReference && feature.isMany() && HibernateUtil.getInstance().isCDOResourceContents(feature)) { setter = new CDOManyAttributeSetter(this, mappedProperty.getName()); } else if (feature instanceof EReference && feature.isMany()) { setter = new CDOManyReferenceSetter(this, mappedProperty.getName()); } else if (feature instanceof EAttribute && feature.isMany()) { setter = new CDOManyAttributeSetter(this, mappedProperty.getName()); } else if (feature instanceof EReference) { setter = new CDOReferenceSetter(this, mappedProperty.getName()); } else { setter = new CDOPropertySetter(this, mappedProperty.getName()); } } HibernateStore hbStore = HibernateStore.getCurrentHibernateStore(); setter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions()); return setter; }
From source file:org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape.java
License:Open Source License
/** * creates children of the shape, /*w w w . j a v a2 s . co m*/ */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected void initModel() { Object ormElement = getOrmElement(); if (ormElement instanceof RootClass) { RootClass rootClass = (RootClass) ormElement; Property identifierProperty = rootClass.getIdentifierProperty(); if (identifierProperty != null) { addChild(new Shape(identifierProperty, getConsoleConfigName())); } KeyValue identifier = rootClass.getIdentifier(); if (identifier instanceof Component) { Component component = (Component) identifier; if (component.isEmbedded()) { Iterator<Property> iterator = ((Component) identifier).getPropertyIterator(); while (iterator.hasNext()) { Property property = iterator.next(); addChild(new Shape(property, getConsoleConfigName())); } } } Iterator<Property> iterator = rootClass.getPropertyIterator(); while (iterator.hasNext()) { Property field = iterator.next(); if (!field.isBackRef()) { if (!field.isComposite()) { final Value val = field.getValue(); Shape bodyOrmShape = null; if (val.isSimpleValue() && !((SimpleValue) val).isTypeSpecified()) { bodyOrmShape = new Shape(field, getConsoleConfigName()); } else { if (val instanceof Collection) { bodyOrmShape = new ComponentShape(field, getConsoleConfigName()); } else { Type type = getTypeUsingExecContext(val); if (type != null && type.isEntityType()) { bodyOrmShape = new ExpandableShape(field, getConsoleConfigName()); } else { bodyOrmShape = new Shape(field, getConsoleConfigName()); } } } addChild(bodyOrmShape); } else { Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName()); addChild(bodyOrmShape); } } } } else if (ormElement instanceof Subclass) { RootClass rootClass = ((Subclass) ormElement).getRootClass(); Property identifierProperty = rootClass.getIdentifierProperty(); if (identifierProperty != null) { addChild(new Shape(identifierProperty, getConsoleConfigName())); } KeyValue identifier = rootClass.getIdentifier(); if (identifier instanceof Component) { Iterator<Property> iterator = ((Component) identifier).getPropertyIterator(); while (iterator.hasNext()) { Property property = iterator.next(); addChild(new Shape(property, getConsoleConfigName())); } } Iterator<Property> iterator = rootClass.getPropertyIterator(); while (iterator.hasNext()) { Property field = iterator.next(); if (!field.isBackRef()) { if (!field.isComposite()) { boolean typeIsAccessible = true; if (field.getValue().isSimpleValue() && ((SimpleValue) field.getValue()).isTypeSpecified()) { try { field.getValue().getType(); } catch (Exception e) { typeIsAccessible = false; } } Shape bodyOrmShape = null; if (typeIsAccessible && field.getValue().isSimpleValue()) { bodyOrmShape = new Shape(field, getConsoleConfigName()); } else if (typeIsAccessible && field.getValue().getType().isEntityType()) { bodyOrmShape = new ExpandableShape(field, getConsoleConfigName()); } else if (typeIsAccessible && field.getValue().getType().isCollectionType()) { bodyOrmShape = new ComponentShape(field, getConsoleConfigName()); } else { bodyOrmShape = new Shape(field, getConsoleConfigName()); } addChild(bodyOrmShape); } else { Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName()); addChild(bodyOrmShape); } } } Iterator<Property> iter = ((Subclass) ormElement).getPropertyIterator(); while (iter.hasNext()) { Property property = iter.next(); if (!property.isBackRef()) { if (!property.isComposite()) { boolean typeIsAccessible = true; if (property.getValue().isSimpleValue() && ((SimpleValue) property.getValue()).isTypeSpecified()) { try { property.getValue().getType(); } catch (Exception e) { typeIsAccessible = false; } } Shape bodyOrmShape = null; if (typeIsAccessible && property.getValue().getType().isEntityType()) { bodyOrmShape = new ExpandableShape(property, getConsoleConfigName()); } else if (typeIsAccessible && property.getValue().getType().isCollectionType()) { bodyOrmShape = new ComponentShape(property, getConsoleConfigName()); } else { bodyOrmShape = new Shape(property, getConsoleConfigName()); } addChild(bodyOrmShape); } else { Shape bodyOrmShape = new ExpandableShape(property, getConsoleConfigName()); addChild(bodyOrmShape); } } } } else if (ormElement instanceof Table) { Iterator iterator = ((Table) getOrmElement()).getColumnIterator(); while (iterator.hasNext()) { Column column = (Column) iterator.next(); Shape bodyOrmShape = new Shape(column, getConsoleConfigName()); addChild(bodyOrmShape); } } }