Hi,
I try to perform bulk insert with below insert statement in Hibernate 4.3.6 / 4.3.7
INSERT INTO TransAttrDO (custCode, partNo, custAttrType, qtyUnit, createServer ) SELECT DISTINCT pp.vendorCode, pp.partNo, 'PT', pp.qtyUnit, 'myhost'
FROM PalletPartInfoDO pp WHERE pp.orderNo = 'SI-HKG-00000001'
I get the exception below. 15:41:22,542 ERROR ErrorCounter:78 - <AST>:8:32: unexpected AST node: DISTINCT 15:41:22,542 ERROR ErrorCounter:73 - <AST>:8:32: unexpected AST node: DISTINCT <AST>:8:32: unexpected AST node: DISTINCT at org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectColumn(SqlGeneratorBase.java:1975) at org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectClause(SqlGeneratorBase.java:544) at org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:186) at org.hibernate.hql.internal.antlr.SqlGeneratorBase.insertStatement(SqlGeneratorBase.java:440) at org.hibernate.hql.internal.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:153) at org.hibernate.hql.internal.ast.exec.BasicExecutor.<init>(BasicExecutor.java:63) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.buildAppropriateStatementExecutor(QueryTranslatorImpl.java:580) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:222) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) When I remove "DISTINCT" keyword, it inserts records successfully. If I executes the select statement with "DISTINCT" without insert, it works fine. I wonder if it is a bug.
Can anyone help?
Thanks, Samuel
|