Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.EntityPersister


  public static OgmCollectionPersister getInverseCollectionPersister(OgmCollectionPersister mainSidePersister) {
    if ( mainSidePersister.isInverse() || !mainSidePersister.isManyToMany() || !mainSidePersister.getElementType().isEntityType() ) {
      return null;
    }

    EntityPersister inverseSidePersister = mainSidePersister.getElementPersister();

    // process collection-typed properties of inverse side and try to find association back to main side
    for ( Type type : inverseSidePersister.getPropertyTypes() ) {
      if ( type.isCollectionType() ) {
        OgmCollectionPersister inverseCollectionPersister = getPersister( mainSidePersister.getFactory(), (CollectionType) type );
        if ( isCollectionMatching( mainSidePersister, inverseCollectionPersister ) ) {
          return inverseCollectionPersister;
        }
View Full Code Here


    Serializable id = (Serializable) propertyType.hydrate(
        resultset, persister.getPropertyColumnNames( propertyIndex ), session, null
    );

    if ( id != null ) {
      EntityPersister hostingEntityPersister = session.getFactory().getEntityPersister(
          propertyType.getReturnedClass().getName()
      );

      return session.getPersistenceContext().getEntity(
          session.generateEntityKey( id, hostingEntityPersister )
View Full Code Here

   * Reads the entity hosting the association from the datastore and applies any property changes from the server
   * side.
   */
  private void updateHostingEntityIfRequired() {
    if ( hostingEntity != null && hostingEntityRequiresReadAfterUpdate() ) {
      EntityPersister entityPersister = getHostingEntityPersister();

      entityPersister.processUpdateGeneratedProperties(
          entityPersister.getIdentifier( hostingEntity, session ),
          hostingEntity,
          new Object[entityPersister.getPropertyNames().length],
          session
      );
    }
  }
View Full Code Here

    public void testColumnMapping() throws Exception {
        Session session = sessionFactory.openSession();
        try {
            Map metadata = sessionFactory.getAllClassMetadata();
            for (Object o : metadata.values()) {
                EntityPersister persister = (EntityPersister) o;
                String className = persister.getEntityName();
                log.debug("Trying select * from: " + className);
                Query q = session.createQuery("from " + className + " c");
                q.iterate();
                log.debug("ok: " + className);
            }
View Full Code Here

  private void scheduleBatchLoadIfNeeded(Serializable id, SessionImplementor session) throws MappingException {
    //cannot batch fetch by unique key (property-ref associations)
    //FIXME support non-pk unique id
    if ( //uniqueKeyPropertyName == null &&
        id != null ) {
      EntityPersister persister = session.getFactory().getEntityPersister( delegate.getAssociatedEntityName() );
      EntityKey entityKey = session.generateEntityKey( id, persister );
      if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
        session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey );
      }
    }
View Full Code Here

    transaction = session.beginTransaction();
    EntityKey key = new EntityKey( new EntityKeyMetadata( "Feeling", new String[] { "UUID" } ), new Object[] { feeling.getUUID() } );
    Map<String, Object> entityTuple = extractEntityTuple( sessions, key );
    final Tuple tuple = new Tuple( new MapTupleSnapshot( entityTuple ) );

    EntityPersister persister = ( (SessionFactoryImplementor) session.getSessionFactory() )
        .getEntityPersister( Feeling.class.getName() );
    OgmLoader loader = new OgmLoader( new OgmEntityPersister[] { (OgmEntityPersister) persister } );
    OgmLoadingContext ogmLoadingContext = new OgmLoadingContext();
    List<Tuple> tuples = new ArrayList<Tuple>();
    tuples.add( tuple );
View Full Code Here

    Serializable id = (Serializable) propertyType.hydrate(
        resultset, persister.getPropertyColumnNames( propertyIndex ), session, null
    );

    if ( id != null ) {
      EntityPersister hostingEntityPersister = session.getFactory().getEntityPersister(
          propertyType.getReturnedClass().getName()
      );

      return session.getPersistenceContext().getEntity(
          session.generateEntityKey( id, hostingEntityPersister )
View Full Code Here

   * Reads the entity hosting the association from the datastore and applies any property changes from the server
   * side.
   */
  private void updateHostingEntityIfRequired() {
    if ( hostingEntity != null && hostingEntityRequiresReadAfterUpdate() ) {
      EntityPersister entityPersister = getHostingEntityPersister();

      entityPersister.processUpdateGeneratedProperties(
          entityPersister.getIdentifier( hostingEntity, session ),
          hostingEntity,
          new Object[entityPersister.getPropertyNames().length],
          session
      );
    }
  }
View Full Code Here

    private Set<String> sequenceGeneratorKeys(SessionFactoryImplementor sessionFactoryImplementor, Neo4jDatastoreProvider provider) {
      Set<String> sequences = new HashSet<String>();
      Map<String, EntityPersister> entityPersisters = sessionFactoryImplementor.getEntityPersisters();
      for ( Map.Entry<String, EntityPersister> entry : entityPersisters.entrySet() ) {
        EntityPersister persister = entry.getValue();
        IdentifierGenerator identifierGenerator = persister.getIdentifierGenerator();
        if ( identifierGenerator instanceof OgmSequenceGenerator ) {
          OgmSequenceGenerator sequenceGenerator = (OgmSequenceGenerator) identifierGenerator;
          sequences.add( sequenceGenerator.generatorKey().toString() );
        }
      }
View Full Code Here

    final AssociationType attributeType = (AssociationType) Helper.resolveType( sessionFactory(), attribute );
    final Joinable joinable = attributeType.getAssociatedJoinable( sessionFactory() );

    if ( joinable.isCollection() ) {
      final EntityPersister elementEntityPersister = ( (QueryableCollection) joinable ).getElementPersister();
      if ( type == null ) {
        type = elementEntityPersister.getMappedClass();
      }
      else  {
        if ( !isTreatableAs( elementEntityPersister, type ) ) {
          throw new IllegalArgumentException(
              String.format(
                  "Collection elements [%s] cannot be treated as requested type [%s] : %s",
                  getAttributeName(),
                  type.getName(),
                  elementEntityPersister.getMappedClass().getName()
              )
          );
        }
      }
    }
    else {
      final EntityPersister entityPersister = (EntityPersister) joinable;
      if ( type == null ) {
        type = entityPersister.getMappedClass();
      }
      else {
        if ( !isTreatableAs( entityPersister, type ) ) {
          throw new IllegalArgumentException(
              String.format(
                  "Attribute [%s] cannot be treated as requested type [%s] : %s",
                  getAttributeName(),
                  type.getName(),
                  entityPersister.getMappedClass().getName()
              )
          );
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.persister.entity.EntityPersister

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.