java - SQL statement to concat strings in MySQL and SQL Server -
java - SQL statement to concat strings in MySQL and SQL Server -
i worked on hibernate.below code worked fine in mssql gives error in mysql
code:
criteria criteria = session.createcriteria(table1.class); criteria.add(restrictions.sqlrestriction("(select this11_.um_email y0_ table2 this11_ this11_.id='"+idvalue+"') '%'+this_.post_id+'%'"));
stacktrace :
you have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '+this_.post_id+'%'' @ line 1 org.hibernate.exception.sqlgrammarexception: not execute query @ org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:67) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:43) @ org.hibernate.loader.loader.dolist(loader.java:2223) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2104) @ org.hibernate.loader.loader.list(loader.java:2099) @ org.hibernate.loader.criteria.criterialoader.list(criterialoader.java:94) @ org.hibernate.impl.sessionimpl.list(sessionimpl.java:1569) @ org.hibernate.impl.criteriaimpl.list(criteriaimpl.java:283)
can help me resolved this?
mysql doesn't allow utilize of +
text; utilize concat()
instead:
... concat('%', this_.post_id, '%')
concat()
works in mssql.
java hibernate
Comments
Post a Comment