Hello, I have a question concerning transient members. In the follwoing code there is an Entity Bean:
package entities; | | import java.io.Serializable; | import java.util.*; | import javax.persistence.*; | | @Entity | public class Node implements Serializable { | | private int id; | private String persistentText; | private String transientText; | | public Node(){} | | public Node(int id) | { | setId(id); | } | | @Id | public int getId() { | return id; | } | | public void setId(int id) { | this.id = id; | } | | public String getPersistentText() { | return persistentText; | } | | public void setPersistentText(String persistentText) { | this.persistentText = persistentText; | } | | @Transient | public String getTransientText() { | return transientText; | } | | public void setTransientText(String transientText) { | this.transientText = transientText; | } | } a Session Bean: package server.sessions; | | import javax.ejb.*; | import javax.persistence.*; | import org.hibernate.*; | import entities.*; | | import java.util.*; | | @Stateful | public class ClientSessionBean implements ClientSessionLocal, ClientSessionRemote{ | | @PersistenceContext private EntityManager manager; | | List<Node> nodes; | Node node; | | public void createNode() | { | node = new Node(1); | node.setTransientText("transient"); | node.setPersistentText("persistent"); | manager.persist(node); | nodes = manager.createQuery("from Node where id=1").getResultList(); | node = nodes.get(0); | System.out.println("createNode persistentText: "+node.getPersistentText()); | System.out.println("createNode transientText: "+node.getTransientText()); | } | | public void showNode() | { | nodes = manager.createQuery("from Node where id=1").getResultList(); | node = nodes.get(0); | System.out.println("showNode persistentText: "+node.getPersistentText()); | System.out.println("showNode transientText: "+node.getTransientText()); | } | | } | and a client, which calls the two methods createNode() and showNode(): package client; | | import javax.naming.InitialContext; | import java.util.*; | import entities.*; | import server.sessions.*; | | public class Client { | | static ClientSession clientSession; | | public static void main(String[] args) { | try { | Hashtable<String,String> env = new Hashtable<String,String>(); | env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); | env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); | env.put("java.naming.provider.url", "localhost"); | InitialContext ctx = new InitialContext(env); | clientSession = (ClientSession)ctx.lookup("ClientSessionBean/remote"); | clientSession.createNode(); | clientSession.showNode(); | } | catch (Exception e) | { | System.out.println(e); | } | } | } I get the following answer: .. 10:59:02,531 INFO [STDOUT] createNode persistentText: persistent 10:59:02,531 INFO [STDOUT] createNode transientText: transient 10:59:02,562 INFO [STDOUT] showNode persistentText: persistent 10:59:02,562 INFO [STDOUT] showNode transientText: null .. Is the last line correct? I've exptected the last line: 10:59:02,562 INFO [STDOUT] showNode transientText: transient Thanks for your efforts. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3927404#3927404 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3927404 ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user