Hibernate dumb question

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.
letsbedecentAsked:
Who is Participating?
 
aozarovConnect With a Mentor Commented:
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
 
suprapto45Commented:
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
 
aozarovCommented:
suprapto45, One of us didn't understand the question. Your POJO is not serializable (which as I said before is not a requirement).
0
 
suprapto45Commented:
Hi aozarov,

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

Regards
Dave
0
 
aozarovCommented:
:-) Good morning!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.