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 3315866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:24:05+00:00 2026-05-17T22:24:05+00:00

I have a grails project that is throwing the following exception: org.springframework.dao.DataIntegrityViolationException: could not

  • 0

I have a grails project that is throwing the following exception:

org.springframework.dao.DataIntegrityViolationException: could not delete: [Role#4]; SQL [delete from role where id=? an
d version=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not del
ete: [Role#4]

In my Role domain, all I did to create this error, was change the definition of one of the variables from

 List<RoleTool> roleTools = new ArrayList<RoleTool>()

to

ArrayList<RoleTool> roleTools = new ArrayList<RoleTool>()

Why is that?

  • 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-17T22:24:05+00:00Added an answer on May 17, 2026 at 10:24 pm

    It’s bad practice in general to specify a concrete class as the declaration type, both in variable declarations and in method signatures. Unless you really need it to be an ArrayList, leave it as List to allow more flexibility.

    I’m not entirely sure what’s happening here, but Hibernate has its own collections classes that it uses for mapped collections, the most commonly used being org.hibernate.collection.PersistentList and org.hibernate.collection.PersistentSet. These implement the List and Set interfaces respectively, but do not extend ArrayList or HashSet or any typical concrete collection. Instead they’re Hibernate internal classes that monitor changes to help with dirty detection when persisting, flushing, etc.

    It’s fine to declare the initial collection as an ArrayList since it’s only read from when saving (it’s Groovy though, so it’s a lot cleaner to just use List<RoleTool> roleTools = []). But Hibernate needs the flexibility of implementing the List/Set interface when loading persistent instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following domain class in my grails project: class Vacation { Date
I have a grails project that contains a few domain objects. I am using
I'm working now together with others in a grails project. I have to write
I have not seen much support for Grails to develop facebook apps.I was just
How do I create a grails war file so that it doesn't have the
I'm writing a small webapp in Grails and I have the following question regarding
I have a grails project with some additional java source files under src/java folder.
I'm using IntelliJ 8.1.2 on Windows to develop a Grails 1.1 project that depends
I have a gant script in my grails project. I would like to do
I have a class in src/groovy in my grails project. How do i make

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.