?
Solved

Hibernate dumb question

Posted on 2005-04-14
5
Medium Priority
?
265 Views
Last Modified: 2013-11-24
hello all,

          Why do we need to serialize the objects (POJO's) that correspond to the tables in database ?? We need to serialize the session beans because of they should be able to handle remote accesses, or either because, they are activated and passivated, but in case of model objects in Hibernate why is serializability a requirement ?? is it only because it is a bean and should satisfy beans properties ??

I feel like this is the dumbest question :o)

thanks anyway.
0
Comment
Question by:letsbedecent
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13785032
Why do you think the POJO needs to be Serializeable?
There is no such requirment from Hibernate. you might want to make them Serializable though if you want to pass them remotely.
The only "Bean" requirements are empty constructor and getter/setters.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13787376
Yes,

You do not have to serialize your POJO in Hibernate. Just create a simple Java Bean and that's it.

I have my POJO for the mapping to Test table in my Oracle database as simple as below and it works.

public class Test {
      private String ID;
      private String name;
      
      
      /**
       * @return
       */
      public String getID() {
            return ID;
      }

      /**
       * @return
       */
      public String getName() {
            return name;
      }

      /**
       * @param string
       */
      public void setID(String string) {
            ID = string;
      }

      /**
       * @param string
       */
      public void setName(String string) {
            name = string;
      }
      
      public String toString() {
            return "ID is " + ID + ", name is " + name;
      }      

}


Regards and good luck
Dave
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13787481
suprapto45, One of us didn't understand the question. Your POJO is not serializable (which as I said before is not a requirement).
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13787665
Hi aozarov,

I am sorry....a kind of blur in the morning :).

Regards
Dave
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13787739
:-) Good morning!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
A solution for Fortify Path Manipulation.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question