File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Using @Transient Annotation in the POJO class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using @Transient Annotation in the POJO class" Watch "Using @Transient Annotation in the POJO class" New topic
Author

Using @Transient Annotation in the POJO class

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Hello defining the @Transient does not allow the property to be persisted ?

Then in what case , where and how the @Transient Annotation wouild be useful to anyone ??


If you want something you never had do something which you had never done
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

RaviNada Kiran wrote:

Then in what case , where and how the @Transient Annotation wouild be useful to anyone ??


By default all the properties of a POJO are marked for persisting. So if you want to skip any properties from being persisted, you can add the @Transient.

[My Blog] [JavaRanch Journal]
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3013
    
  35

For an example, if you need to manage a temporary-state on the bean, you can use the @Transient annotation, so that it will not be mapped to the database.


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
A practical example is user enters a password in the form and it has a field in the backing bean so that bean and you pass that backing bean across the wires through some webservices or EJB then if you mark the password field as transient it won't be passed across the wires.

Hope this helps you.

Thanks,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
 
Don't get me started about those stupid light bulbs.
 
subject: Using @Transient Annotation in the POJO class
 
Similar Threads
making a mostly anonymous Comparator be Serializable
Is there a way to have "calculated field"
about SCBCD
how to exclude a class member from hibernate mapping?
Answers of Sun's Free Proficiency Assessment