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

  • Home
  • SEARCH
  • 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 6043023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:51:15+00:00 2026-05-23T06:51:15+00:00

I’m developing a JEE6 JSF application using NetBeans and its RAD development features. I

  • 0

I’m developing a JEE6 JSF application using NetBeans and its RAD development features. I want to use scaffolding to save time updating controllers and views from Models. The OneToMany associations are generated in the views without any problem (as a dropdown that let you choose the parent entity) but the ManyToMany associations aren’t generated.

Do you know a way to scaffold ManyToMany associations? Which RAD techniques do you use with NetBeans? (plugins, tutorials, materials you recommend)

  • 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-23T06:51:16+00:00Added an answer on May 23, 2026 at 6:51 am

    Actually, the JSF scaffolding with Netbeans is not yet capable of managing Many2Many relationships whatever the Database vendor is. Same thing for database Views.

    As you you can notice, when you want to generate Entities from Database, only tables with an ID (primary key) will be accepted. Yet the wizard will recognize the join tables and will annotate the entities correctly. Seemingly (Netbeans 7.0)
    Example:

    @JoinTable(name = "TOPIC_WRITER", joinColumns = {
            @JoinColumn(name = "topicname", referencedColumnName = "topicname")}, inverseJoinColumns = {
            @JoinColumn(name = "writerid", referencedColumnName = "writerid")})
        @ManyToMany
        private List<Writer> writerList;
    
    @ManyToMany(mappedBy = "writerList")
        private List<Topic> topicList;
    

    Through this link : http://wiki.netbeans.org/JsfCrudGenerator
    You should notice that you have to modify the Entity classes generated before generating the JSF pages (Managed Beans and JPA controllers), if needed, if they are different from the example above.

    As EclipseLink is the default JPA profider used by Netbeans, you should check the EclipseLink site to see examples on how ManytoMany relationship is defined in entity Classes, and see how this is managed in the JPA controller (Java-ee-5) or Stateless Session beans (Java-EE-6) you generated.

    The logical way for the view part was to add in a Create form for example :

    <h:selectManyMenu id="writer" value="#{topicController.selected.writerCollection}" title="#{bundle.CreateBookTitle_writer}" required="true" requiredMessage="Writer needed">
                            <f:selectItems value="#{writerController.itemsAvailableSelectMany}"/>
                        </h:selectManyMenu>
    

    But unfortunately that will not work and will return : Unvalid value. While this seems to be logical : Adding a collection of Writer objects to a Topic object.

    As you can see, the Many2Many relationship is represented by a Collection in the Entity Class so the deal here is how to add a collection to an object.

    I never dealt with ‘many to many’ relationships in a JSF environment so I can’t tell for now how to bring these modifications efficiently. But you may directly ask the JSF Team of Netbeans.org. Or see how the guys from SpringFuse resolved the issue using Spring (Actually they added addObject(){} and removeObject(){} methods in the entity classes concerned by the m2m relationship.

    /**
         * Returns the roles List.
         */
        @Cache(usage = NONSTRICT_READ_WRITE)
        @JoinTable(name = "ACCOUNT_ROLE", joinColumns = @JoinColumn(name = "ACCOUNT_ID"), inverseJoinColumns = @JoinColumn(name = "role_id"))
        @ManyToMany(cascade = PERSIST)
        public List<Role> getRoles() {
            return roles;
        }
    
        /**
         * Set the roles List.
         * It is recommended to use the helper method addRole /  removeRole
         * if you want to preserve referential integrity at the object level.
         *
         * @param roles the List of Role
         */
        public void setRoles(List<Role> roles) {
            this.roles = roles;
        }
    
        /**
         * Helper method to add the passed role to the roles List.
         */
        public boolean addRole(Role role) {
            return getRoles().add(role);
        }
    
        /**
         * Helper method to remove the passed role from the roles List.
         */
        public boolean removeRole(Role role) {
            return getRoles().remove(role);
        }
    
        /**
         * Helper method to determine if the passed role is present in the roles List.
         */
        public boolean containsRole(Role role) {
            return getRoles() != null && getRoles().contains(role);
        }
    

    You can try their online JSF Web app generator and check the generated code to see the difference between theirs and yours, if you don’t mind using Spring Framework to you application.

    However, you can check this Blog article (tutorial), that explains a way to support Many2Many relationship in Netbeans (Java-EE-6) using a simple example (Book – AuthorBook – Author).
    http://ikennaokpala.wordpress.com/2010/06/18/persisting-jpa-many-to-many-relationship/

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.