public RevisionInfoConfiguration(GlobalConfiguration globalCfg) { this.globalCfg = globalCfg; if ( globalCfg.isUseRevisionEntityWithNativeId() ) { revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity"; } else { revisionInfoEntityName = "org.hibernate.envers.enhanced.SequenceIdRevisionEntity"; } revisionInfoIdData = new PropertyData( "id", "id", "field", null ); revisionInfoTimestampData = new PropertyData( "timestamp", "timestamp", "field", null ); modifiedEntityNamesData = new PropertyData( "modifiedEntityNames", "modifiedEntityNames", "field", null ); revisionInfoTimestampType = new LongType(); revisionPropType = "integer"; }
@Override public String[] getRegistrationKeys() { return new String[] { getName(), long.class.getName(), Long.class.getName() }; }
@Override public Comparator<Long> getComparator() { return getJavaTypeDescriptor().getComparator(); }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException { try { if (value == null) { st.setNull(index, type.sqlType()); } else { type.set(st, ((Date) value).getTime(), index, session); } } catch (final Exception e) { } }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, new Long(((DateTime) value).getMillis()), index); } }
public Object nullSafeGet(ResultSet resultSet, String name) throws HibernateException, SQLException { Object value = StandardBasicTypes.LONG.nullSafeGet(resultSet, name); if (value == null) { return null; } return new DateTime(value); }
@Override public int[] sqlTypes() { return new int[] { SQL_TYPE.sqlType() }; }
@Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session, final Object owner) throws HibernateException, SQLException { final Object identifier = type.get(rs, names[0], session); if (identifier == null) { return null; } return new Date((Long) identifier); }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException { try { if (value == null) { st.setNull(index, type.sqlType()); } else { type.set(st, ((Date) value).getTime(), index, session); } } catch (final Exception e) { } }
@SuppressWarnings("deprecation") // until Hibernate 4.x public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, new Long(((DateTime) value).getMillis()), index); } }
@SuppressWarnings("deprecation") // until Hibernate 4.x public Object nullSafeGet(ResultSet resultSet, String name) throws HibernateException, SQLException { Object value = StandardBasicTypes.LONG.nullSafeGet(resultSet, name); if (value == null) { return null; } return new DateTime(value); }
@Override public void nullSafeSet( PreparedStatement preparedStatement, Object value, int index, SharedSessionContractImplementor sessionImplementor) throws HibernateException, SQLException { CustomId customId = (CustomId) value; if ( customId == null ) { preparedStatement.setNull( index, SQL_TYPE.sqlType() ); } else { preparedStatement.setLong( index, customId.getValue() ); } }
@Override public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session, final Object owner) throws HibernateException, SQLException { final Object identifier = type.get(rs, names[0], session); if (identifier == null) { return null; } return new Date((Long) identifier); }
private List<Long> fromInclusiveModificationsForPipelineRange(Session session, String pipelineName, Integer fromCounter, Integer toCounter) { String pipelineIdsSql = queryExtensions.queryFromInclusiveModificationsForPipelineRange(pipelineName, fromCounter, toCounter); SQLQuery pipelineIdsQuery = session.createSQLQuery(pipelineIdsSql); final List ids = pipelineIdsQuery.list(); if (ids.isEmpty()) { return new ArrayList<>(); } String minMaxQuery = " SELECT mods1.materialId as materialId, min(mods1.id) as min, max(mods1.id) as max" + " FROM modifications mods1 " + " INNER JOIN pipelineMaterialRevisions pmr ON (mods1.id >= pmr.actualFromRevisionId AND mods1.id <= pmr.toRevisionId) AND mods1.materialId = pmr.materialId " + " WHERE pmr.pipelineId IN (:ids) " + " GROUP BY mods1.materialId"; SQLQuery query = session.createSQLQuery("SELECT mods.id " + " FROM modifications mods" + " INNER JOIN (" + minMaxQuery + ") as edges on edges.materialId = mods.materialId and mods.id >= min and mods.id <= max" + " ORDER BY mods.materialId ASC, mods.id DESC"); query.addScalar("id", new LongType()); query.setParameterList("ids", ids); return query.list(); }
@Override public String[] getRegistrationKeys() { return new String[] { getName(), long.class.getName(), Long.class.getName() }; }
public Comparator<Long> getComparator() { return getJavaTypeDescriptor().getComparator(); }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.LONG.nullSafeSet(preparedStatement, new Long(((DateTime) value).getMillis()), index); } }
public Object nullSafeGet(ResultSet resultSet, String name) throws HibernateException, SQLException { Object value = StandardBasicTypes.LONG.nullSafeGet(resultSet, name); if (value == null) { return null; } return new DateTime(value); }
private Map<PipelineId, Set<Long>> relevantToLookedUpDependencyMap(Session session, List<Long> pipelineIds) { final int LOOKED_UP_PIPELINE_ID = 2; final int RELEVANT_PIPELINE_ID = 0; final int RELEVANT_PIPELINE_NAME = 1; String pipelineIdsSql = queryExtensions.queryRelevantToLookedUpDependencyMap(pipelineIds); SQLQuery pipelineIdsQuery = session.createSQLQuery(pipelineIdsSql); pipelineIdsQuery.addScalar("id", new LongType()); pipelineIdsQuery.addScalar("name", new StringType()); pipelineIdsQuery.addScalar("lookedUpId", new LongType()); final List<Object[]> ids = pipelineIdsQuery.list(); Map<Long, List<PipelineId>> lookedUpToParentMap = new HashMap<>(); CollectionUtil.CollectionValueMap<Long, PipelineId> lookedUpToRelevantMap = CollectionUtil.collectionValMap(lookedUpToParentMap, new CollectionUtil.ArrayList<>()); for (Object[] relevantAndLookedUpId : ids) { lookedUpToRelevantMap.put((Long) relevantAndLookedUpId[LOOKED_UP_PIPELINE_ID], new PipelineId((String) relevantAndLookedUpId[RELEVANT_PIPELINE_NAME], (Long) relevantAndLookedUpId[RELEVANT_PIPELINE_ID])); } return CollectionUtil.reverse(lookedUpToParentMap); }
@Override public String[] getRegistrationKeys() { return new String[] { getName(), long.class.getName(), Long.class.getName() }; }