[jboss-user] [JBoss Seam] - Newbie - Associated tables - How to get value and persist it
juk
do-not-reply at jboss.com
Thu Nov 29 01:03:15 EST 2007
Hello !
I stuck with this problem for couple days...
My entities are generated using seam-gen.
My Session bean..
| package test.etest.*;
|
| import java.io.Serializable;
| import java.util.List;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.jboss.seam.annotations.Factory;
|
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
|
| import test.etest.*;
|
| @Name("userAction")
| public @Stateful
| class UserActionBean implements Serializable, UserAction {
|
| @DataModel
| private List<User> users;
|
| @DataModelSelection
| private User user;
|
| @PersistenceContext
| private EntityManager em;
|
| @Factory("users")
| public String find() {
|
| users = em.createQuery("select u from User u").getResultList();
| if (users.size() > 0) {
| return "/action.xhtml";
| }
| return null;
|
| }
|
| public void count() {
| // here i need to implement action that will take float value(address.num) from Address entity bean then divide it on value(user.payment) from User entity bean and then persist it to Results table.
| }
|
| public void update() {
| for (User user : users) {
| em.persist(user);
| }
| }
|
| @Remove
| public void terminate() {
| }
|
| public User getUser() {
| return user;
| }
|
| public void setUser(User user) {
| this.user = user;
| }
|
| public List<User> getUsers() {
| return users;
| }
|
| public void setUsers(List<User> users) {
| this.users = users;
| }
|
| }
|
Can anyone help me ?
Regards,
Adam
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108770#4108770
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108770
More information about the jboss-user
mailing list