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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:44:04+00:00 2026-06-11T16:44:04+00:00

In my struts action I retrieve an object X from the database, get a

  • 0

In my struts action I retrieve an object X from the database, get a reference to a one to many collection it contains, add a few objects to this collection and save the original object X.
Problem is I don’t get any error thrown but the table referenced by the one to many collection does not get any new rows added to it.

Heres my action code …

    public String saveSelectedDefinitions()
    {
        WordT wordT = wordDao.get(2);
        Set<DefinitionT> storedDefs = wordT.getDefinitionTs();

        for( int i=0; i<3; i++)
        {
            DefinitionT selectedDef = new DefinitionT();
            selectedDef.setValue("abc");
            selectedDef.setWordT(wordT);
            storedDefs.add(selectedDef);
        }
        wordT.setDefinitionTs(storedDefs);
        wordDao.save(wordT);

        return SUCCESS;
    }

Heres my WordT class

@Entity
@Table(name = "word_t", schema = "public")
public class WordT implements java.io.Serializable {

    private int id;
    private Set<DefinitionT> definitionTs = new HashSet<DefinitionT>(0);

    public WordT() {
    }

    public WordT(int id) {
        this.id = id;
    }

    public WordT(int id,  Set<DefinitionT> definitionTs) {
        this.id = id;
        this.definitionTs = definitionTs;
    }

    @Id
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }


    @OneToMany(fetch = FetchType.EAGER, mappedBy = "wordT")
    public Set<DefinitionT> getDefinitionTs() {
        return this.definitionTs;
    }

    public void setDefinitionTs(Set<DefinitionT> definitionTs) {
        this.definitionTs = definitionTs;
    }

}

and heres my DefinitionT class

    @Entity
    @Table(name = "definition_t", schema = "public")
    public class DefinitionT implements java.io.Serializable {

        private int id;
        private WordT wordT;

        public DefinitionT() {
        }

        public DefinitionT(int id, WordT wordT) {
            this.id = id;
            this.wordT = wordT;
        }

        public DefinitionT(int id, WordT wordT, String value, int typeId,
                Boolean selected) {
            this.id = id;
            this.wordT = wordT;
        }

        @Id
        @Column(name = "id", unique = true, nullable = false)
        public int getId() {
            return this.id;
        }

        public void setId(int id) {
            this.id = id;
        }

        @ManyToOne(fetch = FetchType.EAGER)
        @JoinColumn(name = "word_id", nullable = false)
        public WordT getWordT() {
            return this.wordT;
        }

        public void setWordT(WordT wordT) {
            this.wordT = wordT;
        }

    }

I used Hibernate tools to generate my Daos and Pojos
If I use a DefinitionDao to persist a definitionT instance it persists fine so the table integrity is ok. Why would it not save the collection and not give me any error as to why it failed to do so?

  • 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-06-11T16:44:05+00:00Added an answer on June 11, 2026 at 4:44 pm

    Yo have no cascade on the OneToMany association, so any operation you might do on the word entity doesn’t cascade to its definitions. Moreover, since the definition entity is the owner of the association, you need to set its word property for Hibernate to persist the association.

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

Sidebar

Related Questions

I want to generate xml file from Struts action object. So that I have
I'm having trouble calling a method in one Struts action from a method in
In a Struts Action, I want to get a parameter from the URL or
I need to access the struts.action.extension value in the struts.xml file from an interceptor.
I have a model-driven Struts Web action: public class ModelDrivenAction<T extends Object> implements ModelDriven<T>,
In one of my Struts action I've got the following code in a method:
I have an action in struts2 that will query the database for an object
I retrieve my String from Struts using the following $(document).ready(function( data ) { $('#contextsTextArea').val('<s:property
Can anyone explain, if Struts Action classes are threadsafe in Struts 1.x. Does RequestProcessor
In struts the action scope was defined as <action scope=session .../> How do you

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.