List of usage examples for org.hibernate.type StringType INSTANCE
StringType INSTANCE
To view the source code for org.hibernate.type StringType INSTANCE.
Click Source Link
From source file:com.stagecents.common.hibernate.type.AggregateIdType.java
License:Open Source License
public int[] sqlTypes() { return new int[] { StringType.INSTANCE.sqlType() }; }
From source file:com.stagecents.common.hibernate.type.AggregateIdType.java
License:Open Source License
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { String id = (String) StringType.INSTANCE.get(rs, names[0], session); return new AggregateId(id); }
From source file:com.stagecents.common.hibernate.type.AggregateIdType.java
License:Open Source License
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { StringType.INSTANCE.set(st, null, index, session); } else {/*from ww w . j av a 2s .c o m*/ String id = value.toString(); StringType.INSTANCE.set(st, id, index, session); } }
From source file:com.thesett.catalogue.customtypes.HierarchyAttributeCompositeUserType.java
License:Apache License
/** * Returns an array of string field types, the correct size to hold the hierarchy attribute. * * @return The correct number of string field types. */// ww w . j av a 2 s. c o m public Type[] getPropertyTypes() { // All fields are of type string, just need to know how many there are, so get this from the property names // method. String[] names = getPropertyNames(); // Create a type array big enough for all the fields and fill it with string types. Type[] result = new Type[names.length]; for (int i = 0; i < result.length; i++) { result[i] = StringType.INSTANCE; } return result; }
From source file:com.timesoft.kaitoo.ws.common.CoreContent.java
public static void fildHibernateParameter(final SQLQuery sqlQuery, final Map<String, Object> paramMap) throws HibernateException { Set<String> set = paramMap.keySet(); for (Iterator<String> iter = set.iterator(); iter.hasNext();) { String paramName = iter.next(); Object paramValue = paramMap.get(paramName); if (paramValue != null) { if (paramValue instanceof java.lang.String) { sqlQuery.setParameter(paramName, paramValue.toString().trim(), StringType.INSTANCE); } else if (paramValue instanceof java.lang.Character) { sqlQuery.setParameter(paramName, paramValue, CharacterType.INSTANCE); } else if (paramValue instanceof java.lang.Integer) { sqlQuery.setParameter(paramName, paramValue, IntegerType.INSTANCE); } else if (paramValue instanceof java.util.Date) { sqlQuery.setParameter(paramName, paramValue, DateType.INSTANCE); } else if (paramValue instanceof java.lang.Long) { sqlQuery.setParameter(paramName, paramValue, LongType.INSTANCE); } else if (paramValue instanceof java.sql.Timestamp) { sqlQuery.setParameter(paramName, paramValue, TimestampType.INSTANCE); } else if (paramValue instanceof java.lang.Boolean) { sqlQuery.setParameter(paramName, paramValue, BooleanType.INSTANCE); } else if (paramValue instanceof java.lang.Float) { sqlQuery.setParameter(paramName, paramValue, FloatType.INSTANCE); } else if (paramValue instanceof java.lang.Double) { sqlQuery.setParameter(paramName, paramValue, DoubleType.INSTANCE); } else if (paramValue instanceof java.lang.Byte) { sqlQuery.setParameter(paramName, paramValue, ByteType.INSTANCE); } else if (paramValue instanceof java.util.Calendar) { sqlQuery.setParameter(paramName, paramValue, CalendarType.INSTANCE); }/*ww w.j a va 2s . com*/ } } }
From source file:com.zdtx.ifms.specific.service.monitor.IpCamManager.java
/** * Get IP Camera's users// w ww. ja v a 2s.c o m * @return CamUserVO */ @SuppressWarnings("unchecked") public CamUserVO getCamUsers() { String sql = "SELECT A.USERNAME AS ADMINNAME, A.USERPASS AS ADMINPASS, " + "B.USERNAME AS OPERATORNAME, B.USERPASS AS OPERATORPASS, " + "C.USERNAME AS VIEWERNAME, C.USERPASS AS VIEWERPASS " + "FROM T_CORE_CAM_USER A, T_CORE_CAM_USER B, T_CORE_CAM_USER C " + "WHERE A.AUTHLEVEL = 0 AND B.AUTHLEVEL = 1 AND C.AUTHLEVEL = 2"; SQLQuery query = dao.getSession().createSQLQuery(sql); query.addScalar("adminName", StringType.INSTANCE); query.addScalar("adminPass", StringType.INSTANCE); query.addScalar("operatorName", StringType.INSTANCE); query.addScalar("operatorPass", StringType.INSTANCE); query.addScalar("viewerName", StringType.INSTANCE); query.addScalar("viewerPass", StringType.INSTANCE); query.setResultTransformer(Transformers.aliasToBean(CamUserVO.class)); query.setCacheable(true); CamUserVO camUserVO = ((List<CamUserVO>) query.list()).get(0); return camUserVO; }
From source file:de.rs.hibernate.LocalizedStringType.java
License:Open Source License
@Override public Type[] getPropertyTypes() { return new Type[] { StringType.INSTANCE, LocaleType.INSTANCE }; }
From source file:de.rs.hibernate.LocalizedStringType.java
License:Open Source License
@Override public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { // http://queforum.com/programming-languages-basics/297111-java-usertype-interceptor-handling-i18n-hibernate.html // String text = ""; // String rawId = (String) StringType.INSTANCE.nullSafeGet(rs, names, session, owner); // if (rawId != null && rawId.length() > 0) { // Long labelId = Long.parseLong(rawId); // text = LocalizationLabelUtil.getText(labelId, LocaleContextHolder.getLocale()); // }/*from ww w . j av a 2 s . c o m*/ // return text; assert names.length == 2; String value = (String) StringType.INSTANCE.nullSafeGet(rs, names[VALUE], session, owner); // already handles null check Locale locale = (Locale) LocaleType.INSTANCE.nullSafeGet(rs, names[LOCALE], session, owner); // already handles null check return value == null && locale == null ? null : new LocalizedString(value, locale); }
From source file:de.rs.hibernate.LocalizedStringType.java
License:Open Source License
@Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { StringType.INSTANCE.set(st, null, index, session); LocaleType.INSTANCE.set(st, null, index + 1, session); } else {/*from w w w . j a va 2 s .c o m*/ final LocalizedString string = (LocalizedString) value; StringType.INSTANCE.set(st, string.getValue(), index, session); LocaleType.INSTANCE.set(st, string.getLocale(), index + 1, session); } }
From source file:de.tudarmstadt.ukp.wikipedia.api.Category.java
License:Apache License
/** * @see de.tudarmstadt.ukp.wikipedia.api.Category#Category(Wikipedia, String) */// ww w . ja va2s . c o m private void createCategory(Title title) throws WikiPageNotFoundException { String name = title.getWikiStyleTitle(); Session session = this.wiki.__getHibernateSession(); session.beginTransaction(); Object returnValue; returnValue = session .createNativeQuery("select cat.pageId from Category as cat where cat.name = :name COLLATE utf8_bin") .setParameter("name", name, StringType.INSTANCE).uniqueResult(); session.getTransaction().commit(); // if there is no category with this name, the hibernateCategory is null if (returnValue == null) { hibernateCategory = null; throw new WikiPageNotFoundException("No category with name " + name + " was found."); } else { // now cast it into an integer int pageID = (Integer) returnValue; createCategory(pageID); } }