-->
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.  [ 1 post ] 
Author Message
 Post subject: cant save injected value
PostPosted: Tue Oct 19, 2010 3:56 pm 
Newbie

Joined: Fri Oct 08, 2010 5:35 pm
Posts: 3
Hi.
I write a simple web application.
I use Seam Framework with Hibernate libs.
i have a problem, a cant save injected values...
here are some code:
my stateful bean
Code:
@Name("myStatefulBean")
@Stateful
@Interceptors(SeamInterceptor.class)
@Scope(ScopeType.SESSION)
public class stSB implements stSBRemote, stSBLocal {
    @PersistenceContext
    private Session sessionH;
    @In(create=true)    @Out
    private cartElement cartEl;
    private List<Long> cart;
    public stSB() {
      cart = new ArrayList<Long>();
    }
    public void addItem()
    {
        try
        {
            sessionH.beginTransaction();
            sessionH.save(cartEl);
            sessionH.getTransaction().commit();
        }
        catch (HibernateException e) {
            sessionH.getTransaction().commit();
            System.out.println("saveItem exception");
        }
    }
    // getters - setters, @destroy @remove methods, other methods
}


my entity
Code:
@Entity
@Table(name="CARTELEMENTS")
@Name("cartEl")
public class cartElement implements Serializable{
    private Double price;
    private String name;
    private Date date;
    private Long pid;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    public cartElement(){
       
    }
    public cartElement(Double price, String name, Date date){
        this.price = price;
        this.name = name;
        this.date = date;
    }
    @PostConstruct
    public void init()
    {
        System.out.println("cartElement INIT()");
    }
//getters setters
}


and part of web form
Code:
.....
                <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
                    <h:outputLabel for="name">Name</h:outputLabel>
                    <h:inputText id="name" value="#{cartEl.name}"/>
                 
                    <h:outputLabel for="date">Date</h:outputLabel>
                    <rich:calendar value="#{cartEl.date}"/>
                       
                    <h:outputLabel for="pid">PID</h:outputLabel>
                    <h:inputText id="pid" value="#{cartEl.pid}">
                     <f:validator validatorId="pidValidator"/>
                     <f:converter converterId="strToLongConverter"/>
                    </h:inputText>
                   
                    <h:outputLabel for="price">Price</h:outputLabel>
                    <h:inputText id="price" value="#{cartEl.price}">
        <f:converter converterId="strToDoubleConverter"/>
                    </h:inputText>
                 </h:panelGrid>
             <h:commandButton id="submit" value="Add record" action="#{myStatefulBean.addItem()}"/>


Lets i describe a problem.
After clicking button
<h:commandButton id="submit" value="Add record" action="#{myStatefulBean.addItem()}"/>
values are injected into
Code:
@In(create=true)    @Out
    private cartElement cartEl;


but, when runtime tries to execute code sessionH.save(cartEl); , it throws exception -
Unknown entity: org.domain.seamtest.stateful.cartElement_$$_javassist_seam_3
and values of cartEl are NULL, but proxy JavaBeanInterceptor includes real values.
Image
But if i create a local varriable and copy there field values from injected object (using cartEl.getXXX() methods) - sessionH.save(..) saves object with out any exception, but it is not what i want :(

So, how to solve my problem - how i can persist (save) my @in cartEl object?


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.