-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem when INSERT statement with DISTINCT
PostPosted: Fri Nov 21, 2014 4:10 am 
Newbie

Joined: Fri Nov 21, 2014 3:47 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.