12 Replies Latest reply on Dec 28, 2011 9:17 AM by smarlow

    Jboss7 with Insert into select query

    sabbirali

      In our application we used "insert into select" query for improve performance which is running fine in jboss6.

      But

      with jboss7 it is giving error as below

       

      ErrorMessage:javax.ejb.EJBTransactionRolledbackException: org.hibernate.QueryException: can only generate ids as part of bulk insert with either sequence or post-insert style generators [insert into ScheduleDetails(mstSchedule,articleCode,vendorCode,valuationClass,ruleClass) select  ts.mstSchedule,ma.id.articleCode,tg.vendorCode,tg.valuationClass,'O' from com.eks.ias.service.core.entity.TransGp tg, com.eks.ias.service.core.entity.MstArticle ma,com.eks.ias.service.schedule.entity.TransSchedule ts  where ts.id.scheduleReferenceId = :scheduleRefId and tg.id.siteCode = :siteCode and ma.isDeleted=false and tg.id.articleCode=ma.id.articleCode  and tg.id.siteCode = ts.mstSchedule.mstSite.siteCode and ts.mstSchedule.mstSite.sapVersion = ma.id.sapVersion and ma.mstMc.mcCode = ts.id.mcCode  ]

       

      i think both are using JPA 2.x so it should work on jboss7

        • 1. Re: Jboss7 with Insert into select query
          nickarls

          The Hibernate versions in AS6 and AS7 so it could also be something over there that has changed.

          • 2. Re: Jboss7 with Insert into select query
            sabbirali

            So we need to change code or some alternative available for that.

            In my application i have not change any code...

            • 3. Re: Jboss7 with Insert into select query
              nickarls

              Other thing you might want to check is that all your imports/dependencies are still valid so that you don't accidently lose any annotations related to the ID generation etc. But one would think such things would be compile/deployment errors.

              • 4. Re: Jboss7 with Insert into select query
                sabbirali

                I just remove @Pool anotation [which is not more in jboss7] but it not required for @Id generation.

                 

                and also i remove @IgnoreDependency which is not more required in jboss7.

                 

                if there are deployment error then whole application will not work properly right ?

                But

                other module are working fine except "insert into select" query used module.

                 

                Please see link http://relation.to/21342.lace , JBoss AS7 supporting standard JPA 1.0 and 2.0.

                • 5. Re: Jboss7 with Insert into select query
                  smarlow

                  Could you show  how the involved table (ScheduleDetails) is mapped and what database (dialect really) is in use.

                  • 6. Re: Jboss7 with Insert into select query
                    sabbirali

                    Schedule Details entity looks like below

                     

                    @Entity

                    @Table(name = "SCHEDULE_DETAILS")

                    @SequenceGenerator(name = "SCHEDULE_DETAILS_ID_GENERATOR", sequenceName = "MST_SCHEDULE_DETAILS_ID_SEQ", initialValue = 1, allocationSize = 1)

                    public class ScheduleDetails implements java.io.Serializable

                    {

                    private Long scheduleDetailsId;

                    private MstSchedule mstSchedule;

                    .....

                    // we have some constructor also

                    ...

                         @Id

                              @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SCHEDULE_DETAILS_ID_GENERATOR")

                              @Column(name = "SCHEDULE_DETAILS_ID", unique = true, nullable = false, precision = 38, scale = 0)

                              public Long getScheduleDetailsId() {

                                        return this.scheduleDetailsId;

                              }

                     

                    Only MstSchedule reference in ScheduleDetails, other table does not have relation with ScheduleDetails like TransSchedule,MstArticle,TransGp

                     

                    I used Database dialect : <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />

                    • 7. Re: Jboss7 with Insert into select query
                      smarlow

                      It looks like some code changes might be needed here.  @GeneratedValue(SEQUENCE) maps to org.hibernate.id.enhanced.SequenceStyleGenerator, which isn't checked for in org.hibernate.hql.internal.ast.HqlSqlWalker.supportsIdGenWithBulkInsertion().

                       

                      As previously discussed here, hibernate.id.new_generator_mappings is set to true by default, and as a result, class SequenceStyleGenerator is used instead of class SequenceHiLoGenerator (which is checked for in the above supportsIdGenWithBulkInsertion). 

                       

                      Could you create a Hibernate (against 4.0.0.Final) jira for this bug, the link is here

                       

                      Please post the created jira link here.

                      • 8. Re: Jboss7 with Insert into select query
                        sabbirali

                        I have created JIRA Please find below link

                         

                        https://hibernate.onjira.com/browse/HHH-6920

                         

                        in which version we expected for resolution of above issue.

                        • 9. Re: Jboss7 with Insert into select query
                          smarlow

                          Thanks for adding the jira.  Could you also add the query that is failing as well.

                          • 10. Re: Jboss7 with Insert into select query
                            sabbirali

                            I already add query in discussion but once again i post same please find below

                             

                            insert into ScheduleDetails(mstSchedule,articleCode,vendorCode,valuationClass,ruleClass) select  ts.mstSchedule,ma.id.articleCode,tg.vendorCode,tg.valuationClass,'O' from com.eks.ias.service.core.entity.TransGp tg, com.eks.ias.service.core.entity.MstArticle ma,com.eks.ias.service.schedule.entity.TransSchedule ts  where ts.id.scheduleReferenceId = :scheduleRefId and tg.id.siteCode = :siteCode and ma.isDeleted=false and tg.id.articleCode=ma.id.articleCode  and tg.id.siteCode = ts.mstSchedule.mstSite.siteCode and ts.mstSchedule.mstSite.sapVersion = ma.id.sapVersion and ma.mstMc.mcCode = ts.id.mcCode

                            • 11. Re: Jboss7 with Insert into select query
                              sabbirali

                              Thanx all, Issue got resolved

                              But

                              How i can co-ordinate with jboss7 ?

                              Should i wait for next release version of jboss7 ?

                              From where i get resolved code or resolved jboss7 server [issued fixed] 

                               

                              Please appreciate your reply.

                              • 12. Re: Jboss7 with Insert into select query
                                smarlow

                                You can watch AS7-2076 which also needs Hibernate 4.0.1.Final.