Package org.hibernate.metadata

Examples of org.hibernate.metadata.ClassMetadata


    public void setValueObject(Object valueObject) {
        if (valueObject != null) {

            String classname = getClassname(valueObject.getClass());

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

            Object identifier =
                classMetadata.getIdentifier(valueObject, EntityMode.POJO);
            oidField.setValueObject(identifier);

            copyFrom(valueObject);
        }
    }
View Full Code Here


        try {
            Class valueClass = ClickUtils.classForName(classField.getValue());

            String classname = getClassname(valueClass);

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

            String[] propertyNames = metadata.getPropertyNames();

            boolean[] propertyNullability = metadata.getPropertyNullability();

            for (int i = 0; i < propertyNames.length; i++) {
                Field field = getField(propertyNames[i]);
                if (field != null) {
                    boolean isMandatory = !propertyNullability[i];
View Full Code Here

        Session session = source.create();
    assertNotNull(session);
   
    // make sure it found the entity in the package
    ClassMetadata meta = session.getSessionFactory().getClassMetadata(User.class);
    assertEquals(meta.getEntityName(), "org.example.app0.entities.User");
   
        verify();
    }
View Full Code Here

   * 取得对象的主键名.
   *
   * @return String
   */
  public String getIdName() {
    ClassMetadata meta = sessionFactory.getClassMetadata(entityClass);
    return meta.getIdentifierPropertyName();
  }
View Full Code Here

   * 获取实体名称
   *
   * @return String
   */
  public String getEntityName() {
    ClassMetadata meta = sessionFactory.getClassMetadata(entityClass);
    return meta.getEntityName();
  }
View Full Code Here

        Session session = source.create();
        Assert.assertNotNull(session);

        // make sure it found the entity in the package
        ClassMetadata meta = session.getSessionFactory().getClassMetadata(User.class);
        Assert.assertEquals(meta.getEntityName(), "org.example.app0.entities.User");

        verify();
    }
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

  /**
   * 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

      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

   
    private String getTablename(HasBlob<?> hasBlob) {
        String tablename = entitiesTablenames.get(hasBlob.getClass());
        if (tablename == null) {
            SessionFactory sf = GrailsIntegration.getCurrentSessionFactory();
            ClassMetadata classMetadata = sf.getClassMetadata(hasBlob.getClass());
            if (classMetadata instanceof SingleTableEntityPersister) {
                SingleTableEntityPersister step = (SingleTableEntityPersister) classMetadata;
                tablename = step.getTableName();
                entitiesTablenames.put(hasBlob.getClass(), tablename);
            }
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.