本文整理汇总了Java中org.hibernate.type.LiteralType类的典型用法代码示例。如果您正苦于以下问题:Java LiteralType类的具体用法?Java LiteralType怎么用?Java LiteralType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LiteralType类属于org.hibernate.type包,在下文中一共展示了LiteralType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getRenderText
import org.hibernate.type.LiteralType; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public String getRenderText(SessionFactoryImplementor sessionFactory) {
final Type type = expectedType == null
? heuristicType
: Number.class.isAssignableFrom( heuristicType.getReturnedClass() )
? heuristicType
: expectedType;
try {
final LiteralType literalType = (LiteralType) type;
final Dialect dialect = factory.getDialect();
return literalType.objectToSQLString( constantValue, dialect );
}
catch (Exception t) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + constantExpression, t );
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JavaConstantNode.java
示例2: resolveToLiteralString
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private String resolveToLiteralString(Type type) {
try {
LiteralType literalType = ( LiteralType ) type;
Dialect dialect = factory.getDialect();
return literalType.objectToSQLString( constantValue, dialect );
}
catch ( Throwable t ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + constantExpression, t );
}
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:11,代码来源:JavaConstantNode.java
示例3: addColumn
import org.hibernate.type.LiteralType; //导入依赖的package包/类
public Insert addColumn(String columnName, Object value, LiteralType type) throws Exception {
return addColumn( columnName, type.objectToSQLString(value, dialect) );
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Insert.java
示例4: addColumn
import org.hibernate.type.LiteralType; //导入依赖的package包/类
public Update addColumn(String columnName, Object value, LiteralType type) throws Exception {
return addColumn( columnName, type.objectToSQLString(value, dialect) );
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Update.java
示例5: setConstantValue
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private void setConstantValue(DotNode node, String text, Object value) {
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "setConstantValue() %s -> %s %s", text, value, value.getClass().getName() );
}
// Chop off the rest of the tree.
node.setFirstChild( null );
if ( value instanceof String ) {
node.setType( SqlTokenTypes.QUOTED_STRING );
}
else if ( value instanceof Character ) {
node.setType( SqlTokenTypes.QUOTED_STRING );
}
else if ( value instanceof Byte ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Short ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Integer ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Long ) {
node.setType( SqlTokenTypes.NUM_LONG );
}
else if ( value instanceof Double ) {
node.setType( SqlTokenTypes.NUM_DOUBLE );
}
else if ( value instanceof Float ) {
node.setType( SqlTokenTypes.NUM_FLOAT );
}
else {
node.setType( SqlTokenTypes.CONSTANT );
}
Type type;
try {
type = walker.getSessionFactoryHelper().getFactory().getTypeResolver().heuristicType(
value.getClass().getName()
);
}
catch (MappingException me) {
throw new QueryException( me );
}
if ( type == null ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_DETERMINE_TYPE + node.getText() );
}
try {
LiteralType literalType = (LiteralType) type;
Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
//noinspection unchecked
node.setText( literalType.objectToSQLString( value, dialect ) );
}
catch (Exception e) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + node.getText(), e );
}
node.setDataType( type );
node.setResolvedConstant( text );
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:LiteralProcessor.java
示例6: doToken
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private void doToken(String token, QueryTranslatorImpl q) throws QueryException {
if ( q.isName( StringHelper.root( token ) ) ) { //path expression
doPathExpression( q.unalias( token ), q );
}
else if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) { //named query parameter
q.addNamedParameter( token.substring( 1 ) );
appendToken( q, "?" );
}
else {
Queryable persister = q.getEntityPersisterUsingImports( token );
if ( persister != null ) { // the name of a class
final String discrim = persister.getDiscriminatorSQLValue();
if ( InFragment.NULL.equals(discrim) || InFragment.NOT_NULL.equals(discrim) ) {
throw new QueryException( "subclass test not allowed for null or not null discriminator" );
}
else {
appendToken( q, discrim );
}
}
else {
Object constant;
if (
token.indexOf( '.' ) > -1 &&
( constant = ReflectHelper.getConstantValue( token ) ) != null
) {
Type type;
try {
type = q.getFactory().getTypeResolver().heuristicType( constant.getClass().getName() );
}
catch ( MappingException me ) {
throw new QueryException( me );
}
if ( type == null ) throw new QueryException( QueryTranslator.ERROR_CANNOT_DETERMINE_TYPE + token );
try {
appendToken( q, ( ( LiteralType ) type ).objectToSQLString( constant, q.getFactory().getDialect() ) );
}
catch ( Exception e ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + token, e );
}
}
else { //anything else
String negatedToken = negated ? ( String ) NEGATIONS.get( token.toLowerCase() ) : null;
if ( negatedToken != null && ( !betweenSpecialCase || !"or".equals( negatedToken ) ) ) {
appendToken( q, negatedToken );
}
else {
appendToken( q, token );
}
}
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:54,代码来源:WhereParser.java
示例7: setConstantValue
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private void setConstantValue(DotNode node, String text, Object value) {
if ( log.isDebugEnabled() ) {
log.debug( "setConstantValue() " + text + " -> " + value + " " + value.getClass().getName() );
}
node.setFirstChild( null ); // Chop off the rest of the tree.
if ( value instanceof String ) {
node.setType( SqlTokenTypes.QUOTED_STRING );
}
else if ( value instanceof Character ) {
node.setType( SqlTokenTypes.QUOTED_STRING );
}
else if ( value instanceof Byte ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Short ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Integer ) {
node.setType( SqlTokenTypes.NUM_INT );
}
else if ( value instanceof Long ) {
node.setType( SqlTokenTypes.NUM_LONG );
}
else if ( value instanceof Double ) {
node.setType( SqlTokenTypes.NUM_DOUBLE );
}
else if ( value instanceof Float ) {
node.setType( SqlTokenTypes.NUM_FLOAT );
}
else {
node.setType( SqlTokenTypes.CONSTANT );
}
Type type;
try {
type = TypeFactory.heuristicType( value.getClass().getName() );
}
catch ( MappingException me ) {
throw new QueryException( me );
}
if ( type == null ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_DETERMINE_TYPE + node.getText() );
}
try {
LiteralType literalType = ( LiteralType ) type;
Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
node.setText( literalType.objectToSQLString( value, dialect ) );
}
catch ( Exception e ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + node.getText(), e );
}
node.setDataType( type );
node.setResolvedConstant( text );
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:54,代码来源:LiteralProcessor.java
示例8: doToken
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private void doToken(String token, QueryTranslatorImpl q) throws QueryException {
if ( q.isName( StringHelper.root( token ) ) ) { //path expression
doPathExpression( q.unalias( token ), q );
}
else if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) { //named query parameter
q.addNamedParameter( token.substring( 1 ) );
appendToken( q, "?" );
}
else {
Queryable persister = q.getEntityPersisterUsingImports( token );
if ( persister != null ) { // the name of a class
final String discrim = persister.getDiscriminatorSQLValue();
if ( InFragment.NULL.equals(discrim) || InFragment.NOT_NULL.equals(discrim) ) {
throw new QueryException( "subclass test not allowed for null or not null discriminator" );
}
else {
appendToken( q, discrim );
}
}
else {
Object constant;
if (
token.indexOf( '.' ) > -1 &&
( constant = ReflectHelper.getConstantValue( token ) ) != null
) {
Type type;
try {
type = TypeFactory.heuristicType( constant.getClass().getName() );
}
catch ( MappingException me ) {
throw new QueryException( me );
}
if ( type == null ) throw new QueryException( QueryTranslator.ERROR_CANNOT_DETERMINE_TYPE + token );
try {
appendToken( q, ( ( LiteralType ) type ).objectToSQLString( constant, q.getFactory().getDialect() ) );
}
catch ( Exception e ) {
throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + token, e );
}
}
else { //anything else
String negatedToken = negated ? ( String ) NEGATIONS.get( token.toLowerCase() ) : null;
if ( negatedToken != null && ( !betweenSpecialCase || !"or".equals( negatedToken ) ) ) {
appendToken( q, negatedToken );
}
else {
appendToken( q, token );
}
}
}
}
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:54,代码来源:WhereParser.java
示例9: typeAsLiteralType
import org.hibernate.type.LiteralType; //导入依赖的package包/类
private LiteralType typeAsLiteralType() {
return (LiteralType) getDataType();
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:BooleanLiteralNode.java
注:本文中的org.hibernate.type.LiteralType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论