Java Code Examples for org.hibernate.Hibernate#LONG

The following examples show how to use org.hibernate.Hibernate#LONG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LiteralNode.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Type getDataType() {
	switch ( getType() ) {
		case NUM_INT:
			return Hibernate.INTEGER;
		case NUM_FLOAT:
			return Hibernate.FLOAT;
		case NUM_LONG:
			return Hibernate.LONG;
		case NUM_DOUBLE:
			return Hibernate.DOUBLE;
		case QUOTED_STRING:
			return Hibernate.STRING;
		case TRUE:
		case FALSE:
			return Hibernate.BOOLEAN;
		default:
			return null;
	}
}
 
Example 2
Source File: UserRatingsDaoImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public int deleteAllRatings(OLATResourceable olatResourceable, String resourceableSubPath) {
      String query;
      Object[] values;
      Type[] types;
      // special query when sub path is null
      if (resourceableSubPath == null) {
          query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath is NULL";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      } else {
          query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath=?";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId(), resourceableSubPath };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG, Hibernate.STRING };
      }
      return database.delete(query, values, types);
  }
 
Example 3
Source File: UserCommentsDaoImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  public int deleteAllComments(OLATResourceable olatResourceable, String resourceableSubPath) {
      String query;
      Object[] values;
      Type[] types;
      // special query when sub path is null
      if (resourceableSubPath == null) {
          query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath is NULL";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      } else {
          query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath=?";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId(), resourceableSubPath };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG, Hibernate.STRING };
      }
      return db.delete(query, values, types);
  }
 
Example 4
Source File: UserRatingsDaoImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public int deleteAllRatings(OLATResourceable olatResourceable, String resourceableSubPath) {
      String query;
      Object[] values;
      Type[] types;
      // special query when sub path is null
      if (resourceableSubPath == null) {
          query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath is NULL";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      } else {
          query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath=?";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId(), resourceableSubPath };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG, Hibernate.STRING };
      }
      return database.delete(query, values, types);
  }
 
Example 5
Source File: UserCommentsDaoImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  public int deleteAllComments(OLATResourceable olatResourceable, String resourceableSubPath) {
      String query;
      Object[] values;
      Type[] types;
      // special query when sub path is null
      if (resourceableSubPath == null) {
          query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath is NULL";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      } else {
          query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath=?";
          values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId(), resourceableSubPath };
          types = new Type[] { Hibernate.STRING, Hibernate.LONG, Hibernate.STRING };
      }
      return db.delete(query, values, types);
  }
 
Example 6
Source File: Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Type getReturnType(Type columnType, Mapping mapping) {
	//pre H3.2 behavior: super.getReturnType(ct, m);
	int[] sqlTypes;
	try {
		sqlTypes = columnType.sqlTypes( mapping );
	}
	catch ( MappingException me ) {
		throw new QueryException( me );
	}
	if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in sum()" );
	int sqlType = sqlTypes[0];

	// First allow the actual type to control the return value. (the actual underlying sqltype could actually be different)
	if ( columnType == Hibernate.BIG_INTEGER ) {
		return Hibernate.BIG_INTEGER;
	}
	else if ( columnType == Hibernate.BIG_DECIMAL ) {
		return Hibernate.BIG_DECIMAL;
	}
	else if ( columnType == Hibernate.LONG || columnType == Hibernate.SHORT || columnType == Hibernate.INTEGER) {
		return Hibernate.LONG;
	}
	else if ( columnType == Hibernate.FLOAT || columnType == Hibernate.DOUBLE) {
		return Hibernate.DOUBLE;
	}

	// finally use the sqltype if == on Hibernate types did not find a match.
	if ( sqlType == Types.NUMERIC ) {
		return columnType; //because numeric can be anything
	}
	else if ( sqlType == Types.FLOAT || sqlType == Types.DOUBLE || sqlType == Types.DECIMAL || sqlType == Types.REAL) {
		return Hibernate.DOUBLE;
	}
	else if ( sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.SMALLINT || sqlType == Types.TINYINT ) {
		return Hibernate.LONG;
	}
	else {
		return columnType;
	}
}
 
Example 7
Source File: BinaryArithmeticOperatorNode.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Type resolveDataType() {
	// TODO : we may also want to check that the types here map to exactly one column/JDBC-type
	//      can't think of a situation where arithmetic expression between multi-column mappings
	//      makes any sense.
	Node lhs = getLeftHandOperand();
	Node rhs = getRightHandOperand();
	Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null;
	Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null;
	if ( isDateTimeType( lhType ) || isDateTimeType( rhType ) ) {
		return resolveDateTimeArithmeticResultType( lhType, rhType );
	}
	else {
		if ( lhType == null ) {
			if ( rhType == null ) {
				// we do not know either type
				return Hibernate.DOUBLE; //BLIND GUESS!
			}
			else {
				// we know only the rhs-hand type, so use that
				return rhType;
			}
		}
		else {
			if ( rhType == null ) {
				// we know only the lhs-hand type, so use that
				return lhType;
			}
			else {
				if ( lhType==Hibernate.DOUBLE || rhType==Hibernate.DOUBLE ) return Hibernate.DOUBLE;
				if ( lhType==Hibernate.FLOAT || rhType==Hibernate.FLOAT ) return Hibernate.FLOAT;
				if ( lhType==Hibernate.BIG_DECIMAL || rhType==Hibernate.BIG_DECIMAL ) return Hibernate.BIG_DECIMAL;
				if ( lhType==Hibernate.BIG_INTEGER || rhType==Hibernate.BIG_INTEGER ) return Hibernate.BIG_INTEGER;
				if ( lhType==Hibernate.LONG || rhType==Hibernate.LONG ) return Hibernate.LONG;
				if ( lhType==Hibernate.INTEGER || rhType==Hibernate.INTEGER ) return Hibernate.INTEGER;
				return lhType;
			}
		}
	}
}
 
Example 8
Source File: UserRatingsDaoImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public int deleteAllRatingsIgnoringSubPath(OLATResourceable olatResourceable) {
      // Don't limit to subpath. Ignore if null or not, just delete on the resource
      String query = "from UserRatingImpl where resName=? AND resId=?";
      Object[] values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
      Type[] types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      return database.delete(query, values, types);
  }
 
Example 9
Source File: UserCommentsDaoImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  public int deleteAllCommentsIgnoringSubPath(OLATResourceable olatResourceable) {
      // Don't limit to subpath. Ignore if null or not, just delete on the resource
      String query = "from UserCommentImpl where resName=? AND resId=?";
      Object[] values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
      Type[] types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      return db.delete(query, values, types);
  }
 
Example 10
Source File: UserRatingsDaoImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public int deleteAllRatingsIgnoringSubPath(OLATResourceable olatResourceable) {
      // Don't limit to subpath. Ignore if null or not, just delete on the resource
      String query = "from UserRatingImpl where resName=? AND resId=?";
      Object[] values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
      Type[] types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      return database.delete(query, values, types);
  }
 
Example 11
Source File: UserCommentsDaoImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  public int deleteAllCommentsIgnoringSubPath(OLATResourceable olatResourceable) {
      // Don't limit to subpath. Ignore if null or not, just delete on the resource
      String query = "from UserCommentImpl where resName=? AND resId=?";
      Object[] values = new Object[] { olatResourceable.getResourceableTypeName(), olatResourceable.getResourceableId() };
      Type[] types = new Type[] { Hibernate.STRING, Hibernate.LONG };
      return db.delete(query, values, types);
  }
 
Example 12
Source File: Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Type getReturnType(Type columnType, Mapping mapping) {
	return Hibernate.LONG;
}