Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7067703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:14:04+00:00 2026-05-28T05:14:04+00:00

I am using oracle11g as the database, and trying to do inserts into globalusers

  • 0

I am using oracle11g as the database, and trying to do inserts into globalusers table from my grails service class.
I am retrieving the datasource in grails service like this:

import org.codehaus.groovy.grails.commons.ApplicationHolder as AH 
class UserImportService {
 def dataSource = AH.application.mainContext.dataSource
 def sql = new Sql(dataSource) ;
 String insertQuery="insert into GLOBALUSERS (..) values (..)
                try{
                    sql.execute(insertQuery)
                }
                catch(Exception e){

                    println "Failed to insert : " +insertQuery
                    println "Exception is:" + e;

                }
}

When I run the service from front end I get sql exception saying

Exception is:java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("GRA"."GLOBALUSERS"."ID")

Since I am using a Datasource with my custom dialect which handles ID generation and autoincrement this should be handled by grail/hibernate.

When use the same datasource from other UI .. one by one.. it works..so the dialect is working fine. but this service for batch updates is not working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:14:05+00:00Added an answer on May 28, 2026 at 5:14 am

    Doing direct Sql on the dataSource bean is going to bypass Hibernate’s method of id generation, which, as I understand it, does a nextval() on the appropriate Oracle sequence. So your options are:

    • Use Grails/GORM, where you create the object, populate, and .save()
    • Query the sequence yourself, which would involve doing a nextval() on the sequence, but it would make your Sql Oracle-specific
    • Add an Oracle trigger to the database, which tests if the primary key is set, and if it isn’t does the nextval() sequence query and adds it to the new database row. This will keep your direct Sql compatible with MySql autoincrement and Oracle sequences.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the external table approach with Oracle 11g to load data from
I'm trying to connect my local Oracle 11g database using server explorer in Visual
I am using grails/groovy, and from my controller I am currently doing this for
I'm using Grails 1.3.4, which uses Hibernate, going against an Oracle 11g database. My
I am using Oracle 11g client, with ODP.NET. I am trying to add conditional
Using .Net and Oracle 11g - I've been returning dataTables from a procedure inside
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I'm using oracle 11g. I'm inserting date and time using function SYSDATE into column
I am using oracle 11g and have a table with an XMLType. There are
first some data: we are using Oracle 11g databases. A primary database running on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.