Codota Logo
ClassMetadata.getPropertyValue
Code IndexAdd Codota to your IDE (free)

How to use
getPropertyValue
method
in
org.hibernate.metadata.ClassMetadata

Best Java code snippets using org.hibernate.metadata.ClassMetadata.getPropertyValue (Showing top 14 results out of 315)

  • Common ways to obtain ClassMetadata
private void myMethod () {
ClassMetadata c =
  • Codota IconSessionFactory sessionFactory;Class entityClass;sessionFactory.getClassMetadata(entityClass)
  • Codota IconSessionFactory sessionFactory;String entityName;sessionFactory.getClassMetadata(entityName)
  • Codota IconSessionFactory sessionFactory;Object object;sessionFactory.getClassMetadata(object.getClass())
  • Smart code suggestions by Codota
}
origin: openmrs/openmrs-core

Type propType = metadata.getPropertyType(propName);
if (propType instanceof StringType || propType instanceof TextType) {
  String propertyValue = (String) metadata.getPropertyValue(object, propName);
  if (propertyValue != null) {
    int maxLength = getMaximumPropertyLength(entityClass, propName);
origin: omero/server

/**
 * uses the {@link ClassMetadata} for this {@link Locks} tp retrieve the
 * component value.
 */
public Object getSubtypeValue(int i, int j, Object o) {
  return cm.getPropertyValue(o, subnames[i][j], EntityMode.POJO);
}
origin: org.geomajas.plugin/geomajas-layer-hibernate

@Override
public Entity getChild(String name) throws LayerException {
  Object child = (object == null ? null : metadata.getPropertyValue(object, name, EntityMode.POJO));
  return child == null ? null : new HibernateEntity(child);
}
origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Object getPropertyValue(final Object object, final String propertyName) throws HibernateException {
  return PropertyValueAdapter.adaptToV2(metadata.getPropertyValue(object, propertyName));
}
origin: org.geomajas.plugin/geomajas-layer-hibernate

@Override
public Object getAttribute(String name) throws LayerException {
  if (metadata.getIdentifierPropertyName().equals(name)) {
    return getId(name);
  }
  return object == null ? null : metadata.getPropertyValue(object, name, EntityMode.POJO);
}
origin: ldlqdsdcn/eidea4

public Object getPropertyValue(Object object, String property) {
  if (getIdProperty().equals(property))
    return getIdValue(object);
  else
    return metadata.getPropertyValue(object, property);
}
origin: OpenNMS/opennms

  /**
   * <p>Parse the {@link DataAccessException} to see if special problems were
   * encountered while performing the query. See issue NMS-5029 for examples of
   * stack traces that can be thrown from these calls.</p>
   * {@see http://issues.opennms.org/browse/NMS-5029}
   */
  private void logExtraSaveOrUpdateExceptionInformation(final T entity, final DataAccessException e) {
    Throwable cause = e;
    while (cause.getCause() != null) {
      if (cause.getMessage() != null) {
        if (cause.getMessage().contains("duplicate key value violates unique constraint")) {
          final ClassMetadata meta = getSessionFactory().getClassMetadata(m_entityClass);
          LOG.warn("Duplicate key constraint violation, class: {}, key value: {}", m_entityClass.getName(), meta.getPropertyValue(entity, meta.getIdentifierPropertyName(), EntityMode.POJO));
          break;
        } else if (cause.getMessage().contains("given object has a null identifier")) {
          LOG.warn("Null identifier on object, class: {}: {}", m_entityClass.getName(), entity.toString());
          break;
        }
      }
      cause = cause.getCause();
    }
  }
}
origin: stackoverflow.com

 class IntrospectClassMetadata extends BasicTransformerAdapter {
 PassThroughResultTransformer rt = PassThroughResultTransformer.INSTANCE;
 public Object transformTuple(Object[] tuple, String[] aliases) {
  final Object o = rt.transformTuple(tuple, aliases);
  ClassMetadata cm = sf.getClassMetadata(o.getClass());
  List<String> pns = new ArrayList<String>(Arrays.asList(cm.getPropertyNames()));
  Map<String, Object> m = new HashMap<String, Object>();
  for(String pn : pns) {
   m.put(pn, cm.getPropertyValue(o, pn));
  }
  m.put(cm.getIdentifierPropertyName(), cm.getIdentifier(o));
  return m;
 }
}
origin: com.arsframework/ars-database

/**
 * 获取对象属性值
 *
 * @param sessionFactory 会话工厂
 * @param object         对象实例
 * @param property       属性名称
 * @return 属性值
 */
public static Object getValue(SessionFactory sessionFactory, Object object, String property) {
  if (object == null) {
    return null;
  }
  ClassMetadata metadata = getClassMetadata(sessionFactory, object.getClass());
  Object value = metadata.getPropertyValue(object, property);
  if (value != null && !Hibernate.isInitialized(value)) {
    Type type = metadata.getPropertyType(property);
    return type.isCollectionType() ? new ArrayList<Object>(0) : null;
  }
  return value;
}
origin: stackoverflow.com

import org.hibernate.SessionFactory;
 import org.hibernate.metadata.ClassMetadata;
 import org.hibernate.type.CollectionType;
 import org.hibernate.type.Type;
 // you should already have these somewhere:
 SessionFactory sessionFactory = ...
 Session session = ...
 MyEntity myEntity = ...
 // this fetches all collections by inspecting the Hibernate Metadata.
 ClassMetadata classMetadata = sessionFactory.getClassMetadata(MyEntity.class);
 String[] propertyNames = classMetadata.getPropertyNames();
 for (String name : propertyNames)
 {
   Object propertyValue = classMetadata.getPropertyValue(myEntity, name, EntityMode.POJO);
   Type propertyType = classMetadata.getPropertyType(name);
   if (propertyValue != null && propertyType instanceof CollectionType)
   {
     CollectionType s = (CollectionType) propertyType;
     s.getElementsIterator(propertyValue, session);   // this triggers the loading of the data
   }
 }
origin: zanata/zanata-platform

metadata.getPropertyValue(value, property)));
origin: org.geomajas.plugin/geomajas-layer-hibernate

@Override
public EntityCollection getChildCollection(String name) throws LayerException {
  Type type = metadata.getPropertyType(name);
  if (type instanceof CollectionType) {
    CollectionType ct = (CollectionType) type;
    Collection coll = (Collection) metadata.getPropertyValue(object, name, EntityMode.POJO);
    if (coll == null) {
      // normally should not happen, hibernate instantiates it automatically
      coll = (Collection) ct.instantiate(0);
      metadata.setPropertyValue(object, name, coll, EntityMode.POJO);
    }
    String entityName = ct.getAssociatedEntityName((SessionFactoryImplementor) sessionFactory);
    ClassMetadata childMetadata = sessionFactory.getClassMetadata(entityName);
    return new HibernateEntityCollection(metadata, childMetadata, object, coll);
  } else {
    throw new LayerException(ExceptionCode.FEATURE_MODEL_PROBLEM);
  }
}
origin: hibernate/hibernate

/**
 * @see org.hibernate.id.IdentifierGenerator#generate(org.hibernate.engine.SessionImplementor, java.lang.Object)
 */
public Serializable generate(SessionImplementor session, Object object)
throws HibernateException {
  Object associatedObject = session.getFactory()
      .getClassMetadata( entityName )
      .getPropertyValue( object,  propertyName, session.getEntityMode() );
  if (associatedObject==null) throw new IdentifierGenerationException(
    "attempted to assign id from null one-to-one property: " + propertyName
  );
  Serializable id;
  try {
    id = ForeignKeys.getEntityIdentifierIfNotUnsaved(null, associatedObject, session); //TODO: use associated entity name
  }
  catch (TransientObjectException toe) {
    id = session.save(associatedObject);
  }
  if ( session.contains(object) ) {
    //abort the save (the object is already saved by a circular cascade)
    return IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR;
    //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association");
  }
  return id;
}
origin: jboss.jboss-embeddable-ejb3/hibernate-all

.getPropertyValue( object, propertyName, session.getEntityMode() );
org.hibernate.metadataClassMetadatagetPropertyValue

Javadoc

Get the value of a particular (named) property

Popular methods of ClassMetadata

  • getIdentifierPropertyName
    Get the name of the identifier property (or return null)
  • getIdentifierType
    Get the identifier Hibernate type
  • getEntityName
    The name of the entity
  • getPropertyNames
    Get the names of the class' persistent properties
  • getMappedClass
    The persistent class, or null
  • getIdentifier
  • getPropertyType
    Get the type of a particular (named) property
  • getPropertyTypes
    Get the Hibernate types of the class properties
  • getPropertyValues
    Extract the property values from the given entity.
  • hasIdentifierProperty
    Does this class have an identifier property?
  • setPropertyValue
    Set the value of a particular (named) property
  • instantiate
  • setPropertyValue,
  • instantiate,
  • getVersionProperty,
  • setIdentifier,
  • getPropertyNullability,
  • getVersion,
  • isVersioned,
  • getNaturalIdentifierProperties,
  • getPropertyLaziness

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • onCreateOptionsMenu (Activity)
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now