-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Jpa ManyToMany Problem
PostPosted: Sat Jan 24, 2009 5:10 pm 
Newbie

Joined: Sat Jan 24, 2009 4:48 pm
Posts: 2
Hi
I am using jpa with seam. I want to add relations on database tables.
I have two entities: Project and Employee. When I use @ManyToOne this code is working well:
Code:
@Entity
public class Employee implements Serializable
{
    // seam-gen attributes (you should probably edit these)
    private Long id;
    private Integer version;
    private String name;
    private String code;
    private Project project;

    @Id @GeneratedValue
    public Long getId() {
        return id;
    }

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

    .........
    .........
    @ManyToOne
    public Fakulte getProject() {
      return project;
     }

     public void setFakulte(Project project) {
      this.project = project;
     }
}


And I get the project like this:
Code:
<h:selectOneMenu value="#{employeeHome.instance.project}">
                   <s:selectItems var="project" value="#{projectList.resultList}" label="#{project.name}"></s:selectItems>
                  <s:convertEntity></s:convertEntity>
                </h:selectOneMenu>

But when I want to do a manytomany relation, this doesn't work. Then I have to change the project variable type to List. This works but doesn't insert record to newly created relational project_employee table. Is there a problem in h:selectOneMenu? What might be the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2009 12:45 pm 
Newbie

Joined: Sat Jan 24, 2009 4:48 pm
Posts: 2
i am still waiting. i need solution. pls help


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2009 5:00 pm 
Beginner
Beginner

Joined: Sat Oct 04, 2003 7:00 am
Posts: 26
Location: Roma,IT
Hi,
using manytomany impies the property is a collection. List is a good choice.

The selectOneMenu, as the word tell you, permit to select only one bean, so it is not a good choice.

I think you can try on SeamFramework forums.

_________________
Filippo De Luca
Developer at WURFL-Pro


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.