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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:21:56+00:00 2026-05-28T17:21:56+00:00

I am trying to persist a Class with a LinkedList Attribute but can’t seem

  • 0

I am trying to persist a Class with a LinkedList Attribute but can’t seem to get it right. Here is my code and my mapping:

 import java.util.LinkedList;
 public class Stuff implements java.io.Serializable {
    private long id;
private LinkedList<Image> images;


public Stuff() {
}


public Stuff(long Id) {
    id = Id;
}

public long getId() {
    return id;
}

public void setId(long mealId) {
    id = mealId;
}


public LinkedList<Image> getNumberImages(int number) {
    assert (number >= 0);
    return (LinkedList<Image>) images.subList(0, number) ;
}

public LinkedList<Image> getImages() {
    return images;
}
    public LinkedList<Image> setImages(LinkedList<Image> images) {
    this.images = images;
}


public void addImage(Image image) {
    if (!images.contains(image)) {
        images.add(image);
    }
}

Hibernate mapping:

<hibernate-mapping>
    <class name="data.Stuff" table="Stuff">
        <id name="id" type="long" access="field">
            <column name="ID" />
            <generator class="assigned" />
        </id>
        <list name="images" inverse="false" table="IMAGE" lazy="true" access="field">
            <key>
                <column name="ID" />
            </key>
            <list-index></list-index>
            <one-to-many class="data.Image" />
        </list>
    </class>
</hibernate-mapping>

It seems I can persist objects of the Class Stuff like this but when I try to recover them the following error occurres :

Hibernate: select stuff0_.ID as ID0_, stuff0_.NAME as NAME0_, meal0_.GROUPING as GROUPING0_ from MEAL meal0_
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of data.Meal.images
  • 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-28T17:21:57+00:00Added an answer on May 28, 2026 at 5:21 pm

    Generally, Hibernate will provide its own implementations for collections so you should prefer interfaces to specific implementations. It’s probably attempting to assign a different kind of list to images and failing. You would have to change your field to List<Image>.

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

Sidebar

Related Questions

I'm stuck trying to get the mapping I want to persist correctly. For my
Im trying to persist some data but im getting an error here. Declaration of
I'm trying to instantiate a generic class in Spring, but I get following exception:
i am trying to persist two entities(with one to many relationship) using jpa but
I'm trying to setup Spring using Hibernate and JPA, but when trying to persist
I am trying to get LINQ to SQL to persist changes to an attached
I am trying to persist and ArrayList, but it does not work. Everything is
I am trying to persist a large class called an Authorizer which holds a
I'm trying to persist some data that I get from a form in a
Can a class inherit from Entity Framework class and still persist back to the

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.