Package org.hibernate.metadata

Examples of org.hibernate.metadata.ClassMetadata


      return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED;
    }

    public Object getIdentifier(Object entity) {
      final Class entityClass = Hibernate.getClass( entity );
      final ClassMetadata classMetadata = emf.getSessionFactory().getClassMetadata( entityClass );
      if (classMetadata == null) {
        throw new IllegalArgumentException( entityClass + " is not an entity" );
      }
      //TODO does that work for @IdClass?
      return classMetadata.getIdentifier( entity, EntityMode.POJO );
    }
View Full Code Here


    return super.invokeInterceptor( session, entity, entry, values, persister ) || isDirty;
  }

  private boolean copyState(Object entity, Type[] types, Object[] state, SessionFactory sf) {
    // copy the entity state into the state array and return true if the state has changed
    ClassMetadata metadata = sf.getClassMetadata( entity.getClass() );
    Object[] newState = metadata.getPropertyValues( entity );
    int size = newState.length;
    boolean isDirty = false;
    for ( int index = 0; index < size ; index++ ) {
      if ( !types[index].isEqual( state[index], newState[index] ) ) {
        isDirty = true;
View Full Code Here

    return super.invokeInterceptor( session, entity, entry, values, persister ) || isDirty;
  }

  private boolean copyState(Object entity, Type[] types, Object[] state, SessionFactory sf) {
    // copy the entity state into the state array and return true if the state has changed
    ClassMetadata metadata = sf.getClassMetadata( entity.getClass() );
    Object[] newState = metadata.getPropertyValues( entity, EntityMode.POJO );
    int size = newState.length;
    boolean isDirty = false;
    for ( int index = 0; index < size ; index++ ) {
      if ( !types[index].isEqual( state[index], newState[index], EntityMode.POJO ) ) {
        isDirty = true;
View Full Code Here

  /**
   * copy the entity state into the state array and return true if the state has changed
   */
  private boolean copyState(Object entity, Type[] types, Object[] state, SessionFactory sf) {
    ClassMetadata metadata = sf.getClassMetadata( entity.getClass() );
    Object[] newState = metadata.getPropertyValues( entity, EntityMode.POJO );
    int size = newState.length;
    boolean isDirty = false;
    for ( int index = 0; index < size ; index++ ) {
      if ( !types[index].isEqual( state[index], newState[index], EntityMode.POJO ) ) {
        isDirty = true;
View Full Code Here

   * @param entity an actual entity object, not a proxy!
   */
  public String toString(Object entity, EntityMode entityMode) throws HibernateException {

    // todo : this call will not work for anything other than pojos!
    ClassMetadata cm = factory.getClassMetadata( entity.getClass() );

    if ( cm==null ) return entity.getClass().getName();

    Map result = new HashMap();

    if ( cm.hasIdentifierProperty() ) {
      result.put(
        cm.getIdentifierPropertyName(),
        cm.getIdentifierType().toLoggableString( cm.getIdentifier( entity, entityMode ), factory )
      );
    }

    Type[] types = cm.getPropertyTypes();
    String[] names = cm.getPropertyNames();
    Object[] values = cm.getPropertyValues( entity, entityMode );
    for ( int i=0; i<types.length; i++ ) {
      if ( !names[i].startsWith("_") ) {
        String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
          values[i].toString() :
          types[i].toLoggableString( values[i], factory );
        result.put( names[i], strValue );
      }
    }
    return cm.getEntityName() + result.toString();
  }
View Full Code Here

   * @param entity an actual entity object, not a proxy!
   */
  public String toString(Object entity, EntityMode entityMode) throws HibernateException {

    // todo : this call will not work for anything other than pojos!
    ClassMetadata cm = factory.getClassMetadata( entity.getClass() );

    if ( cm==null ) return entity.getClass().getName();

    Map result = new HashMap();

    if ( cm.hasIdentifierProperty() ) {
      result.put(
        cm.getIdentifierPropertyName(),
        cm.getIdentifierType().toLoggableString( cm.getIdentifier( entity, entityMode ), factory )
      );
    }

    Type[] types = cm.getPropertyTypes();
    String[] names = cm.getPropertyNames();
    Object[] values = cm.getPropertyValues( entity, entityMode );
    for ( int i=0; i<types.length; i++ ) {
      if ( !names[i].startsWith("_") ) {
        String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
          values[i].toString() :
          types[i].toLoggableString( values[i], factory );
        result.put( names[i], strValue );
      }
    }
    return cm.getEntityName() + result.toString();
  }
View Full Code Here

      return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED;
    }

    public Object getIdentifier(Object entity) {
      final Class entityClass = Hibernate.getClass( entity );
      final ClassMetadata classMetadata = emf.getSessionFactory().getClassMetadata( entityClass );
      if (classMetadata == null) {
        throw new IllegalArgumentException( entityClass + " is not an entity" );
      }
      //TODO does that work for @IdClass?
      return classMetadata.getIdentifier( entity, EntityMode.POJO );
    }
View Full Code Here

      return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED;
    }

    public Object getIdentifier(Object entity) {
      final Class entityClass = Hibernate.getClass( entity );
      final ClassMetadata classMetadata = emf.getSessionFactory().getClassMetadata( entityClass );
      if (classMetadata == null) {
        throw new IllegalArgumentException( entityClass + " is not an entity" );
      }
      //TODO does that work for @IdClass?
      return classMetadata.getIdentifier( entity );
    }
View Full Code Here

      return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED;
    }

    public Object getIdentifier(Object entity) {
      final Class entityClass = Hibernate.getClass( entity );
      final ClassMetadata classMetadata = emf.getSessionFactory().getClassMetadata( entityClass );
      if (classMetadata == null) {
        throw new IllegalArgumentException( entityClass + " is not an entity" );
      }
      //TODO does that work for @IdClass?
      return classMetadata.getIdentifier( entity );
    }
View Full Code Here

        classField.setValue(valueClass.getName());
        add(classField);

        String classname = getClassname(valueClass);

        ClassMetadata classMetadata =
            getSessionFactory().getClassMetadata(classname);

        Type identifierType = classMetadata.getIdentifierType();
        oidField = new HiddenField(FO_ID, identifierType.getReturnedClass());
        add(oidField);
    }
View Full Code Here

TOP

Related Classes of org.hibernate.metadata.ClassMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.