List of usage examples for org.hibernate.type StandardBasicTypes STRING
StringType STRING
To view the source code for org.hibernate.type StandardBasicTypes STRING.
Click Source Link
From source file:com.openkm.dao.NodeMailDAO.java
License:Open Source License
/** * Search nodes by keyword/*from w w w .java2 s . c om*/ */ @SuppressWarnings("unchecked") public List<NodeMail> findByKeyword(String keyword) throws DatabaseException { log.debug("findByKeyword({})", keyword); final String qs = "from NodeMail nm where :keyword in elements(nm.keywords) order by nm.name"; final String sql = "select NBS_UUID from OKM_NODE_KEYWORD, OKM_NODE_MAIL " + "where NKW_KEYWORD = :keyword and NKW_NODE = NBS_UUID"; List<NodeMail> ret = new ArrayList<NodeMail>(); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); if (Config.NATIVE_SQL_OPTIMIZATIONS) { SQLQuery q = session.createSQLQuery(sql); q.setCacheable(true); q.setCacheRegion(CACHE_MAILS_BY_KEYWORD); q.setString("keyword", keyword); q.addScalar("NBS_UUID", StandardBasicTypes.STRING); for (String uuid : (List<String>) q.list()) { NodeMail nMail = (NodeMail) session.load(NodeMail.class, uuid); ret.add(nMail); } } else { Query q = session.createQuery(qs).setCacheable(true); q.setString("keyword", keyword); ret = q.list(); } // Security Check SecurityHelper.pruneNodeList(ret); initialize(ret); HibernateUtil.commit(tx); log.debug("findByKeyword: {}", ret); return ret; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.processpuzzle.fundamental_types.possiblevalue.domain.PossibleValueDefinitionTypeMapping.java
License:Open Source License
public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { String valueDefinitionClassDiscriminator = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[0], session);//from ww w. j av a 2 s . co m Double minAmount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[1], session); String minUnitSymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[2], session); Double maxAmount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[3], session); String maxUnitSymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[4], session); String possibleValues = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[5], session); ProcessPuzzleContext applicationContext = UserRequestManager.getInstance().getApplicationContext(); MeasurementContext measurementContext = applicationContext.getMeasurementContext(); if (valueDefinitionClassDiscriminator != null && valueDefinitionClassDiscriminator.endsWith("QuantityRange")) { if (minAmount != null && minUnitSymbol != null && maxAmount != null && maxUnitSymbol != null) { Quantity minValue = new Quantity(minAmount, measurementContext.findUnitBySymbol(minUnitSymbol)); Quantity maxValue = new Quantity(maxAmount, measurementContext.findUnitBySymbol(maxUnitSymbol)); return new QuantityRange(minValue, maxValue); } } else if (valueDefinitionClassDiscriminator != null && valueDefinitionClassDiscriminator.endsWith("QuantityEnumeration")) { return new QuantityEnumeration(possibleValues); } else if (valueDefinitionClassDiscriminator != null && valueDefinitionClassDiscriminator.endsWith("StringEnumeration")) { return new StringEnumeration(possibleValues); } return null; }
From source file:com.processpuzzle.fundamental_types.possiblevalue.domain.PossibleValueDefinitionTypeMapping.java
License:Open Source License
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value != null) { PossibleValueDefinition valueDefinition = (PossibleValueDefinition) value; StandardBasicTypes.STRING.nullSafeSet(statement, valueDefinition.getClass().getName(), index, session); if (valueDefinition instanceof QuantityRange) { QuantityRange range = (QuantityRange) valueDefinition; if (range.getMinValue() != null && range.getMaxValue() != null) { StandardBasicTypes.DOUBLE.nullSafeSet(statement, range.getMinValue().getAmount(), index + 1, session);/*from ww w. j a va 2 s. c o m*/ StandardBasicTypes.STRING.nullSafeSet(statement, range.getMinValue().getUnit().getSymbol(), index + 2, session); StandardBasicTypes.DOUBLE.nullSafeSet(statement, range.getMaxValue().getAmount(), index + 3, session); StandardBasicTypes.STRING.nullSafeSet(statement, range.getMaxValue().getUnit().getSymbol(), index + 4, session); } else { statement.setNull(index + 1, Types.DOUBLE); statement.setNull(index + 2, Types.VARCHAR); statement.setNull(index + 3, Types.DOUBLE); statement.setNull(index + 4, Types.VARCHAR); } statement.setNull(index + 5, Types.VARCHAR); } else if (valueDefinition instanceof StringParseable) { statement.setNull(index + 1, Types.DOUBLE); statement.setNull(index + 2, Types.VARCHAR); statement.setNull(index + 3, Types.DOUBLE); statement.setNull(index + 4, Types.VARCHAR); StandardBasicTypes.STRING.nullSafeSet(statement, ((StringParseable) valueDefinition).stringValue(), index + 5, session); } } else { statement.setNull(index, Types.VARCHAR); statement.setNull(index + 1, Types.DOUBLE); statement.setNull(index + 2, Types.VARCHAR); statement.setNull(index + 3, Types.DOUBLE); statement.setNull(index + 4, Types.VARCHAR); statement.setNull(index + 5, Types.VARCHAR); } }
From source file:com.processpuzzle.fundamental_types.possiblevalue.domain.PossibleValueDefinitionTypeMapping.java
License:Open Source License
public Type[] getPropertyTypes() { return new Type[] { StandardBasicTypes.STRING, StandardBasicTypes.DOUBLE, StandardBasicTypes.STRING, StandardBasicTypes.DOUBLE, StandardBasicTypes.STRING, StandardBasicTypes.STRING }; }
From source file:com.processpuzzle.persistence.typemapping.domain.MoneyTypeMapping.java
License:Open Source License
public Type[] getPropertyTypes() { return new Type[] { StandardBasicTypes.DOUBLE, StandardBasicTypes.STRING }; }
From source file:com.processpuzzle.persistence.typemapping.domain.MoneyTypeMapping.java
License:Open Source License
public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Double amount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[0], session); String currencySymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[1], session); if (amount == null && currencySymbol == null) return null; else {//from ww w.j av a 2 s .c o m ProcessPuzzleContext applicationContext = UserRequestManager.getInstance().getApplicationContext(); MeasurementContext measurementContext = applicationContext.getMeasurementContext(); return new Money(amount, measurementContext.findUnitBySymbol(currencySymbol)); } }
From source file:com.processpuzzle.persistence.typemapping.domain.MoneyTypeMapping.java
License:Open Source License
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { Money money = (Money) value;/*from ww w .j a v a 2s .c om*/ if (money != null && money.getAmount() != null && money.getUnit() != null) { StandardBasicTypes.DOUBLE.nullSafeSet(statement, money.getAmount(), index, session); // StandardBasicTypes.CURRENCY.nullSafeSet(statement, money.getUnit().getSymbol(), index+1); String currenySymbol = money.getUnit().getSymbol(); ProcessPuzzleContext applicationContext = UserRequestManager.getInstance().getApplicationContext(); MeasurementContext measurementContext = applicationContext.getMeasurementContext(); if (measurementContext.findUnitBySymbol(currenySymbol) == null) { throw new MoneyTypeMappingException("Unit must have currency symbol in MonyTypeMapping"); } StandardBasicTypes.STRING.nullSafeSet(statement, currenySymbol, index + 1, session); } else { statement.setNull(index, Types.DOUBLE); statement.setNull(index + 1, Types.VARCHAR); } }
From source file:com.processpuzzle.persistence.typemapping.domain.QuantityTypeMapping.java
License:Open Source License
public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Double amount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[0], session); String unitSymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[1], session); if (amount == null && unitSymbol == null) return null; else {/*from w w w .j a v a 2 s. co m*/ ProcessPuzzleContext applicationContext = UserRequestManager.getInstance().getApplicationContext(); MeasurementContext measurementContext = applicationContext.getMeasurementContext(); return new Quantity(amount, measurementContext.findUnitBySymbol(unitSymbol)); } }
From source file:com.processpuzzle.persistence.typemapping.domain.QuantityTypeMapping.java
License:Open Source License
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { Quantity quantity = (Quantity) value; if (quantity != null && quantity.getAmount() != null && quantity.getUnit() != null) { StandardBasicTypes.DOUBLE.nullSafeSet(statement, quantity.getAmount(), index, session); StandardBasicTypes.STRING.nullSafeSet(statement, quantity.getUnit().getSymbol(), index + 1, session); } else {//from w w w . j a v a 2 s .co m statement.setNull(index, Types.DOUBLE); statement.setNull(index + 1, Types.VARCHAR); } }
From source file:com.pushinginertia.commons.domain.usertype.IpAddressAndCountryUserType.java
License:Open Source License
@Override public void nullSafeSet(final PreparedStatement statement, final Object value, final int index, final SessionImplementor session) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, StandardBasicTypes.STRING.sqlType()); statement.setNull(index + 1, StandardBasicTypes.STRING.sqlType()); return;//ww w. ja v a 2 s. co m } final IpAddressAndCountry entity = (IpAddressAndCountry) value; statement.setString(index, entity.getIpAddress().getIpAddress()); statement.setString(index + 1, entity.getCountryCode()); }