congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClassMetadata.getPropertyValue
Code IndexAdd Tabnine 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)

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

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JFrame (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now