@Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { final Object entity = getEntity( key ); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
private static net.sf.hibernate.NonUniqueObjectException adaptNonUniqueObjectException( final org.hibernate.NonUniqueObjectException ex) { final String message = ex.getMessage(); return new net.sf.hibernate.NonUniqueObjectException(ex.getMessage(), ex.getIdentifier(), null) { @Override public String getMessage() { return message; } @Override public String toString() { return toStringWithClassName(this, net.sf.hibernate.cache.CacheException.class); } }; }
public static int saveWithoutUpdate(List<FixedValue> fixedValues){ return HibernateUtil.withSession((session) -> { int saved = 0; session.beginTransaction(); for (FixedValue fixedValue : fixedValues){ try{ session.save(fixedValue); saved++; }catch(NonUniqueObjectException e){ log.warn("Could not save fixed value for subject {}, attribute {}: {}", fixedValue.getId().getSubject().getLabel(), fixedValue.getId().getAttribute().getLabel(), e.getMessage()); } if ( saved % 50 == 0 ) { session.flush(); session.clear(); } } session.getTransaction().commit(); return saved; }); } }
public static int saveWithoutUpdate(List<TimedValue> timedValues){ return HibernateUtil.withSession((session) -> { int saved = 0; session.beginTransaction(); for (TimedValue timedValue : timedValues){ try{ session.save(timedValue); saved++; }catch(NonUniqueObjectException e){ log.warn("Could not save timed value for subject {}, attribute {}, time {}: {}", timedValue.getId().getSubject().getLabel(), timedValue.getId().getAttribute().getDescription(), timedValue.getId().getTimestamp().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), e.getMessage()); } if ( saved % 50 == 0 ) { session.flush(); session.clear(); } } session.getTransaction().commit(); return saved; }); }
throw new NonUniqueObjectException( id, persister.getEntityName() );
public static int save(List<FixedValue> fixedValues){ return HibernateUtil.withSession((session) -> { int saved = 0; session.beginTransaction(); for (FixedValue fixedValue : fixedValues){ try{ session.saveOrUpdate(fixedValue); saved++; }catch(NonUniqueObjectException e){ // This is happening because the TFL stations contain a duplicate ID log.warn("Could not save fixed value for subject {}, attribute {}: {}", fixedValue.getId().getSubject().getLabel(), fixedValue.getId().getAttribute().getLabel(), e.getMessage()); } if ( saved % 50 == 0 ) { // because batch size in the hibernate config is 50 session.flush(); session.clear(); } } session.getTransaction().commit(); return saved; }); }
throw new NonUniqueObjectException( event.getEntityId(), event.getEntityClassName() );
public static int save(List<TimedValue> timedValues){ return HibernateUtil.withSession((session) -> { int saved = 0; session.beginTransaction(); for (TimedValue timedValue : timedValues){ try{ session.saveOrUpdate(timedValue); saved++; }catch(NonUniqueObjectException e){ // This is happening because the TFL stations contain a duplicate ID log.warn("Could not save timed value for subject {}, attribute {}, time {}: {}", timedValue.getId().getSubject().getLabel(), timedValue.getId().getAttribute().getDescription(), timedValue.getId().getTimestamp().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), e.getMessage()); } if ( saved % 50 == 0 ) { // because batch size in the hibernate config is 50 session.flush(); session.clear(); } } session.getTransaction().commit(); return saved; }); }
@Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { final Object entity = getEntity( key ); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
/** * Attempts to check whether the given key represents an entity already loaded within the * current session. * @param object The entity reference against which to perform the uniqueness check. * @throws HibernateException */ @Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { Object entity = getEntity(key); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
/** * Attempts to check whether the given key represents an entity already loaded within the * current session. * @param object The entity reference against which to perform the uniqueness check. * @throws HibernateException */ public void checkUniqueness(EntityKey key, Object object) throws HibernateException { Object entity = getEntity(key); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
/** * Attempts to check whether the given key represents an entity already loaded within the * current session. * @param object The entity reference against which to perform the uniqueness check. * @throws HibernateException */ @Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { Object entity = getEntity(key); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
/** * Attempts to check whether the given key represents an entity already loaded within the * current session. * @param id The key to be checked. * @param object The entity reference against which to perform the uniqueness check. * @throws HibernateException */ public void checkUniqueness(Serializable id, EntityPersister persister, Object object) throws HibernateException { Object entity = getEntity( new EntityKey( id, persister, session.getEntityMode() ) ); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( id, persister.getEntityName() ); } }
throw new NonUniqueObjectException( id, persister.getEntityName() );
throw new NonUniqueObjectException( id, persister.getEntityName() );
throw new NonUniqueObjectException( event.getEntityId(), event.getEntityClassName() );
throw new NonUniqueObjectException( id, descriptor.getEntityName() );
throw new NonUniqueObjectException( id, persister.getEntityName() );
throw new NonUniqueObjectException( id, persister.getEntityName() );
throw new NonUniqueObjectException( event.getEntityId(), event.getEntityClassName() );