Codota Logo
org.hibernate.metadata
Code IndexAdd Codota to your IDE (free)

How to use org.hibernate.metadata

Best Java code snippets using org.hibernate.metadata (Showing top 20 results out of 540)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: hibernate/hibernate-orm

/**
 * Return the values of the mapped properties of the object
 */
@SuppressWarnings( {"UnusedDeclaration"})
Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) throws HibernateException;
origin: hibernate/hibernate-orm

/**
 * Inject the identifier value into the given entity.
 *
 * @param entity The entity to inject with the identifier value.
 * @param id The value to be injected as the identifier.
 * @param session The session from which is requests originates
 *
 * @deprecated Use {@link #setIdentifier(Object, Serializable, SharedSessionContractImplementor)} instead
 */
@Deprecated
default void setIdentifier(Object entity, Serializable id, SessionImplementor session) {
  setIdentifier( entity, id, (SharedSessionContractImplementor) session );
}
origin: hibernate/hibernate-orm

/**
 * Get the identifier of an instance (throw an exception if no identifier property)
 *
 * @param entity The entity for which to get the identifier
 * @param session The session from which the request originated
 *
 * @return The identifier
 *
 * @deprecated Use {@link #getIdentifier(Object, SharedSessionContractImplementor)} instead
 */
@Deprecated
default Serializable getIdentifier(Object entity, SessionImplementor session) {
  return getIdentifier( entity, (SharedSessionContractImplementor) session );
}
origin: my2iu/Jinq

private void scanClassMetadata(ClassMetadata meta)
{
 Class<?> entityClass = meta.getMappedClass();
 String[] names = meta.getPropertyNames();
 Type[] types = meta.getPropertyTypes();
 for (int n = 0; n < names.length; n++)
 {
   String fieldName = names[n];
   Type type = types[n];
   registerEntityField(entityClass, fieldName, type);
 }
 if (meta.getIdentifierPropertyName() != null)
   registerEntityField(entityClass, meta.getIdentifierPropertyName(), meta.getIdentifierType());
 
 //System.out.println(names + " " + types);
}

origin: BroadleafCommerce/BroadleafCommerce

@Override
public Map<String, Object> getIdMetadata(Class<?> entityClass, HibernateEntityManager entityManager) {
  entityClass = getNonProxyImplementationClassIfNecessary(entityClass);
  Map<String, Object> response = new HashMap<>();
  SessionFactory sessionFactory = entityManager.getSession().getSessionFactory();
  
  ClassMetadata metadata = sessionFactory.getClassMetadata(entityClass);
  if (metadata == null) {
    return null;
  }
  
  String idProperty = metadata.getIdentifierPropertyName();
  response.put("name", idProperty);
  Type idType = metadata.getIdentifierType();
  response.put("type", idType);
  return response;
}
origin: BroadleafCommerce/BroadleafCommerce

for (Object item : sessionFactory.getAllClassMetadata().values()) {
  ClassMetadata metadata = (ClassMetadata) item;
  String idProperty = metadata.getIdentifierPropertyName();
  Class<?> mappedClass = metadata.getMappedClass();
  Field idField;
  try {
origin: BroadleafCommerce/BroadleafCommerce

  @Override
  public Field getIdField(Class<?> clazz, Session session) {
    clazz = getNonProxyImplementationClassIfNecessary(clazz);
    ClassMetadata metadata = session.getSessionFactory().getClassMetadata(clazz);
    Field idField = ReflectionUtils.findField(clazz, metadata.getIdentifierPropertyName());
    idField.setAccessible(true);
    return idField;
  }
}
origin: hibernate/hibernate-orm

/**
 * Add parent and child entity names so that we know how to rearrange dependencies
 *
 * @param action The action being sorted
 * @param batchIdentifier The batch identifier of the entity affected by the action
 */
private void addParentChildEntityNames(AbstractEntityInsertAction action, BatchIdentifier batchIdentifier) {
  Object[] propertyValues = action.getState();
  ClassMetadata classMetadata = action.getPersister().getClassMetadata();
  if ( classMetadata != null ) {
    Type[] propertyTypes = classMetadata.getPropertyTypes();
    Type identifierType = classMetadata.getIdentifierType();
    for ( int i = 0; i < propertyValues.length; i++ ) {
      Object value = propertyValues[i];
      Type type = propertyTypes[i];
      addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
    }
    if ( identifierType.isComponentType() ) {
      CompositeType compositeType = (CompositeType) identifierType;
      Type[] compositeIdentifierTypes = compositeType.getSubtypes();
      for ( Type type : compositeIdentifierTypes ) {
        addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
      }
    }
  }
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<String> getPropertyNames(Class<?> entityClass, HibernateEntityManager entityManager) {
  entityClass = getNonProxyImplementationClassIfNecessary(entityClass);
  ClassMetadata metadata = getSessionFactory(entityManager).getClassMetadata(entityClass);
  List<String> propertyNames = new ArrayList<>();
  Collections.addAll(propertyNames, metadata.getPropertyNames());
  return propertyNames;
}
origin: BroadleafCommerce/BroadleafCommerce

protected void populateCaches(String targetMode, Map<String, Object> managerMap) {
  final EntityManager em = getEntityManager(managerMap);
  final PlatformTransactionManager txManager = getTransactionManager(managerMap);
  final EJB3ConfigurationDao ejb3ConfigurationDao = getEJB3ConfigurationDao(managerMap);
  SessionFactory sessionFactory = em.unwrap(Session.class).getSessionFactory();
  for (Object item : sessionFactory.getAllClassMetadata().values()) {
    ClassMetadata metadata = (ClassMetadata) item;
    Class<?> mappedClass = metadata.getMappedClass();
    String managerCacheKey = buildManagerCacheKey(targetMode, mappedClass);
    ENTITY_MANAGER_CACHE.put(managerCacheKey, em);
    TRANSACTION_MANAGER_CACHE.put(managerCacheKey, txManager);
    String ejb3ConfigDaoCacheKey = buildEJB3ConfigDaoCacheKey(mappedClass);
    if (!EJB3_CONFIG_DAO_CACHE.containsKey(ejb3ConfigDaoCacheKey)) {
      EJB3_CONFIG_DAO_CACHE.put(ejb3ConfigDaoCacheKey, ejb3ConfigurationDao);
    }
  }
}
origin: hibernate/hibernate-orm

@Override
public void nullSafeSet(
    PreparedStatement st,
    Object value,
    int index,
    SharedSessionContractImplementor session) throws HibernateException, SQLException {
  String entityName = session.getFactory().getClassMetadata((Class) value).getEntityName();
  Loadable entityPersister = (Loadable) session.getFactory().getEntityPersister(entityName);
  underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session);
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<Type> getPropertyTypes(Class<?> entityClass, HibernateEntityManager entityManager) {
  entityClass = getNonProxyImplementationClassIfNecessary(entityClass);
  ClassMetadata metadata = getSessionFactory(entityManager).getClassMetadata(entityClass);
  List<Type> propertyTypes = new ArrayList<>();
  Collections.addAll(propertyTypes, metadata.getPropertyTypes());
  return propertyTypes;
}
origin: hibernate/hibernate-orm

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 ( ( state[index] == LazyPropertyInitializer.UNFETCHED_PROPERTY &&
        newState[index] != LazyPropertyInitializer.UNFETCHED_PROPERTY ) ||
        ( state[index] != newState[index] && !types[index].isEqual( state[index], newState[index] ) ) ) {
      isDirty = true;
      state[index] = newState[index];
    }
  }
  return isDirty;
}
origin: hibernate/hibernate-orm

/**
 * Create a class instance initialized with the given identifier
 *
 * @param id The identifier value to use (may be null to represent no value)
 * @param session The session from which the request originated.
 *
 * @return The instantiated entity.
 *
 * @deprecated (since 5.3) Use the form accepting SharedSessionContractImplementor
 * instead
 */
@Deprecated
default Object instantiate(Serializable id, SessionImplementor session) {
  return instantiate( id, (SharedSessionContractImplementor) session );
}
origin: hibernate/hibernate-orm

@Test
public void testMappingProperties() {
  ClassMetadata metaData = sessionFactory().getClassMetadata(
      Citizen.class
  );
  assertTrue(
      "Class should have a natural key", metaData
          .hasNaturalIdentifier()
  );
  int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
  assertTrue( "Wrong number of elements", propertiesIndex.length == 2 );
}
origin: BroadleafCommerce/BroadleafCommerce

Class<?> foreignResponseType = foreignMetadata.getIdentifierType().getReturnedClass();
if (foreignResponseType.equals(String.class)) {
  metadata.put(addMetadataFromFieldTypeRequest.getRequestedPropertyName(),
    setForeignKeyProperty(foreignMetadata.getIdentifierPropertyName());
((BasicFieldMetadata) metadata.get(addMetadataFromFieldTypeRequest.getRequestedPropertyName()))
    .setForeignKeyClass(foreignKeyClass);
Class<?> foreignResponseType = foreignMetadata.getIdentifierType().getReturnedClass();
if (foreignResponseType.equals(String.class)) {
  metadata.put(addMetadataFromFieldTypeRequest.getRequestedPropertyName(),
    setForeignKeyProperty(foreignMetadata.getIdentifierPropertyName());
((BasicFieldMetadata) metadata.get(addMetadataFromFieldTypeRequest.getRequestedPropertyName())).
    setForeignKeyClass(foreignKeyClass);
origin: BroadleafCommerce/BroadleafCommerce

@Override
public Field getIdField(Class<?> clazz, EntityManager em) {
  clazz = getNonProxyImplementationClassIfNecessary(clazz);
  ClassMetadata metadata = em.unwrap(Session.class).getSessionFactory().getClassMetadata(clazz);
  Field idField = ReflectionUtils.findField(clazz, metadata.getIdentifierPropertyName());
  idField.setAccessible(true);
  return idField;
}
origin: stackoverflow.com

 ClassMetadata classMetadata = sessionFactory.getClassMetadata(AppTaskConfig.class);
String[] propertyNames = classMetadata.getPropertyNames();
origin: BroadleafCommerce/BroadleafCommerce

for (Object item : sessionFactory.getAllClassMetadata().values()) {
  ClassMetadata metadata = (ClassMetadata) item;
  Class<?> mappedClass = metadata.getMappedClass();
  if (mappedClass != null && ceilingClass.isAssignableFrom(mappedClass)) {
    entities.add(mappedClass);
origin: hibernate/hibernate-orm

@Test
public void testMappingProperties() {
  log.warn("Commented out test");
  ClassMetadata metaData = sessionFactory().getClassMetadata(
      NaturalIdOnManyToOne.class
  );
  assertTrue(
      "Class should have a natural key", metaData
          .hasNaturalIdentifier()
  );
  int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
  assertTrue( "Wrong number of elements", propertiesIndex.length == 1 );
}
org.hibernate.metadata

Most used classes

  • ClassMetadata
    Exposes entity class metadata to the application
  • CollectionMetadata
    Exposes collection metadata to the application
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