POJO Classes being serialized with no read/write usage











up vote
1
down vote

favorite
1












I am new to SPRING and was assigned to work on project currently under development. Unfortunately development of the project has been slow so people have come and gone so I cant ask them why some things were done a certain way.



The project is a web service using SPRING.



They are using a View - Controller - Service (interface & implementation) - DAO (interface & implementation) - POJO (class used to transport data structure across layers).



Every POJO I have checked implementations serialization. On closer examination and search of the code, none of the POJO's are ever written or read, either in the POJO itself or any other file. Which has lead me to ask why its being done.



The POJO's are populated from Oracle statements in the DAO, which bubble upto the view, and then will bubble back down to the DAO where they information from them are written to the database using Oracle statements. The POJO itself is not written into the database.



Does SPRING MVC or java web applications require serialization and it is being used in the background? Is it needed to transmit the data between server and client connections? Is there a good reason that all the POJO's are using it that someone new would not recognize?










share|improve this question






















  • Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
    – Angelo Immediata
    Nov 7 at 17:41










  • @AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
    – Fering
    Nov 7 at 17:54















up vote
1
down vote

favorite
1












I am new to SPRING and was assigned to work on project currently under development. Unfortunately development of the project has been slow so people have come and gone so I cant ask them why some things were done a certain way.



The project is a web service using SPRING.



They are using a View - Controller - Service (interface & implementation) - DAO (interface & implementation) - POJO (class used to transport data structure across layers).



Every POJO I have checked implementations serialization. On closer examination and search of the code, none of the POJO's are ever written or read, either in the POJO itself or any other file. Which has lead me to ask why its being done.



The POJO's are populated from Oracle statements in the DAO, which bubble upto the view, and then will bubble back down to the DAO where they information from them are written to the database using Oracle statements. The POJO itself is not written into the database.



Does SPRING MVC or java web applications require serialization and it is being used in the background? Is it needed to transmit the data between server and client connections? Is there a good reason that all the POJO's are using it that someone new would not recognize?










share|improve this question






















  • Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
    – Angelo Immediata
    Nov 7 at 17:41










  • @AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
    – Fering
    Nov 7 at 17:54













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I am new to SPRING and was assigned to work on project currently under development. Unfortunately development of the project has been slow so people have come and gone so I cant ask them why some things were done a certain way.



The project is a web service using SPRING.



They are using a View - Controller - Service (interface & implementation) - DAO (interface & implementation) - POJO (class used to transport data structure across layers).



Every POJO I have checked implementations serialization. On closer examination and search of the code, none of the POJO's are ever written or read, either in the POJO itself or any other file. Which has lead me to ask why its being done.



The POJO's are populated from Oracle statements in the DAO, which bubble upto the view, and then will bubble back down to the DAO where they information from them are written to the database using Oracle statements. The POJO itself is not written into the database.



Does SPRING MVC or java web applications require serialization and it is being used in the background? Is it needed to transmit the data between server and client connections? Is there a good reason that all the POJO's are using it that someone new would not recognize?










share|improve this question













I am new to SPRING and was assigned to work on project currently under development. Unfortunately development of the project has been slow so people have come and gone so I cant ask them why some things were done a certain way.



The project is a web service using SPRING.



They are using a View - Controller - Service (interface & implementation) - DAO (interface & implementation) - POJO (class used to transport data structure across layers).



Every POJO I have checked implementations serialization. On closer examination and search of the code, none of the POJO's are ever written or read, either in the POJO itself or any other file. Which has lead me to ask why its being done.



The POJO's are populated from Oracle statements in the DAO, which bubble upto the view, and then will bubble back down to the DAO where they information from them are written to the database using Oracle statements. The POJO itself is not written into the database.



Does SPRING MVC or java web applications require serialization and it is being used in the background? Is it needed to transmit the data between server and client connections? Is there a good reason that all the POJO's are using it that someone new would not recognize?







java spring oracle serialization pojo






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 17:37









Fering

1288




1288












  • Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
    – Angelo Immediata
    Nov 7 at 17:41










  • @AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
    – Fering
    Nov 7 at 17:54


















  • Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
    – Angelo Immediata
    Nov 7 at 17:41










  • @AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
    – Fering
    Nov 7 at 17:54
















Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
– Angelo Immediata
Nov 7 at 17:41




Spring MVC end/or java web applications don't require serialization. I guess they wrote the code in that way in order to have all serializable object
– Angelo Immediata
Nov 7 at 17:41












@AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
– Fering
Nov 7 at 17:54




@AngeloImmediata Is there a reason why they would want that? Some design principle, carry over from old practices, ...?
– Fering
Nov 7 at 17:54












3 Answers
3






active

oldest

votes

















up vote
0
down vote













Use of Java's default serialization is a normal way for regular POJOs.




Java specifies a default way in which objects can be serialized. Java classes can override this default behavior. Custom serialization can be particularly useful when trying to serialize an object that has some unserializable attributes.







share|improve this answer





















  • I actually used that article to perform my searches to see if they were actually being read or written anywhere.
    – Fering
    Nov 7 at 17:52










  • @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
    – user7294900
    Nov 7 at 17:57










  • I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
    – Fering
    Nov 7 at 18:05


















up vote
0
down vote













Depends on technologies used in the layers as well as implementation details.



If persistence is done using JPA/Hibernate then POJOs most likely will need to be Serializable.



In case if the POJO is passed to view via servlet session and session replication is on then you need to have your POJOs Serializable.






share|improve this answer





















  • Why would JPA entities need to be serializable?
    – chrylis
    Nov 7 at 17:58










  • @chrylis stackoverflow.com/questions/2020904/…
    – tsolakp
    Nov 7 at 18:05










  • That question doesn't actually have any correct answers. The accepted answer is nonsense.
    – chrylis
    Nov 7 at 19:13










  • The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
    – tsolakp
    Nov 7 at 19:50


















up vote
0
down vote



accepted










This might not be the correct answer, but so far in my case it matches and explains what I am seeing. I have not seen this information mentioned else where, but the answer is well upvoted, has been around for awhile, and is from a high reputation user, so I am inclined to trust it.



There is an answer from another question where they mention something important.




As to the why you need to worry about serialization, this is because most Java servlet containers like Tomcat require classes to implement Serializable whenever instances of those classes are been stored as an attribute of the HttpSession. That is because the HttpSession may need to be saved on the local disk file system or even transferred over network when the servlet container needs to shutdown/restart or is being placed in a cluster of servers wherein the session has to be synchronized.




The application Im working on DOES use Tomcat, so if this is a restriction or behavior, then I can easily see why all the POJO's are created in this fashion, simply to avoid issues that might develop later, and is a result of experience having worked with this all before, and its that experience that I am lacking.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194829%2fpojo-classes-being-serialized-with-no-read-write-usage%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Use of Java's default serialization is a normal way for regular POJOs.




    Java specifies a default way in which objects can be serialized. Java classes can override this default behavior. Custom serialization can be particularly useful when trying to serialize an object that has some unserializable attributes.







    share|improve this answer





















    • I actually used that article to perform my searches to see if they were actually being read or written anywhere.
      – Fering
      Nov 7 at 17:52










    • @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
      – user7294900
      Nov 7 at 17:57










    • I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
      – Fering
      Nov 7 at 18:05















    up vote
    0
    down vote













    Use of Java's default serialization is a normal way for regular POJOs.




    Java specifies a default way in which objects can be serialized. Java classes can override this default behavior. Custom serialization can be particularly useful when trying to serialize an object that has some unserializable attributes.







    share|improve this answer





















    • I actually used that article to perform my searches to see if they were actually being read or written anywhere.
      – Fering
      Nov 7 at 17:52










    • @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
      – user7294900
      Nov 7 at 17:57










    • I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
      – Fering
      Nov 7 at 18:05













    up vote
    0
    down vote










    up vote
    0
    down vote









    Use of Java's default serialization is a normal way for regular POJOs.




    Java specifies a default way in which objects can be serialized. Java classes can override this default behavior. Custom serialization can be particularly useful when trying to serialize an object that has some unserializable attributes.







    share|improve this answer












    Use of Java's default serialization is a normal way for regular POJOs.




    Java specifies a default way in which objects can be serialized. Java classes can override this default behavior. Custom serialization can be particularly useful when trying to serialize an object that has some unserializable attributes.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 7 at 17:46









    user7294900

    18.4k93056




    18.4k93056












    • I actually used that article to perform my searches to see if they were actually being read or written anywhere.
      – Fering
      Nov 7 at 17:52










    • @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
      – user7294900
      Nov 7 at 17:57










    • I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
      – Fering
      Nov 7 at 18:05


















    • I actually used that article to perform my searches to see if they were actually being read or written anywhere.
      – Fering
      Nov 7 at 17:52










    • @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
      – user7294900
      Nov 7 at 17:57










    • I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
      – Fering
      Nov 7 at 18:05
















    I actually used that article to perform my searches to see if they were actually being read or written anywhere.
    – Fering
    Nov 7 at 17:52




    I actually used that article to perform my searches to see if they were actually being read or written anywhere.
    – Fering
    Nov 7 at 17:52












    @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
    – user7294900
    Nov 7 at 17:57




    @Fering you will add serialization if you can have circular (object as a member of itself) serialization for example
    – user7294900
    Nov 7 at 17:57












    I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
    – Fering
    Nov 7 at 18:05




    I went and looked, but I dont see any circular serialization happening. It was a quick look so I might have missed something, but all I am seeing is that the class is used in a list to represent the database information, is sent up to the view, and then brought back down and put into the database if something was changed.
    – Fering
    Nov 7 at 18:05












    up vote
    0
    down vote













    Depends on technologies used in the layers as well as implementation details.



    If persistence is done using JPA/Hibernate then POJOs most likely will need to be Serializable.



    In case if the POJO is passed to view via servlet session and session replication is on then you need to have your POJOs Serializable.






    share|improve this answer





















    • Why would JPA entities need to be serializable?
      – chrylis
      Nov 7 at 17:58










    • @chrylis stackoverflow.com/questions/2020904/…
      – tsolakp
      Nov 7 at 18:05










    • That question doesn't actually have any correct answers. The accepted answer is nonsense.
      – chrylis
      Nov 7 at 19:13










    • The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
      – tsolakp
      Nov 7 at 19:50















    up vote
    0
    down vote













    Depends on technologies used in the layers as well as implementation details.



    If persistence is done using JPA/Hibernate then POJOs most likely will need to be Serializable.



    In case if the POJO is passed to view via servlet session and session replication is on then you need to have your POJOs Serializable.






    share|improve this answer





















    • Why would JPA entities need to be serializable?
      – chrylis
      Nov 7 at 17:58










    • @chrylis stackoverflow.com/questions/2020904/…
      – tsolakp
      Nov 7 at 18:05










    • That question doesn't actually have any correct answers. The accepted answer is nonsense.
      – chrylis
      Nov 7 at 19:13










    • The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
      – tsolakp
      Nov 7 at 19:50













    up vote
    0
    down vote










    up vote
    0
    down vote









    Depends on technologies used in the layers as well as implementation details.



    If persistence is done using JPA/Hibernate then POJOs most likely will need to be Serializable.



    In case if the POJO is passed to view via servlet session and session replication is on then you need to have your POJOs Serializable.






    share|improve this answer












    Depends on technologies used in the layers as well as implementation details.



    If persistence is done using JPA/Hibernate then POJOs most likely will need to be Serializable.



    In case if the POJO is passed to view via servlet session and session replication is on then you need to have your POJOs Serializable.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 7 at 17:48









    tsolakp

    4,46611219




    4,46611219












    • Why would JPA entities need to be serializable?
      – chrylis
      Nov 7 at 17:58










    • @chrylis stackoverflow.com/questions/2020904/…
      – tsolakp
      Nov 7 at 18:05










    • That question doesn't actually have any correct answers. The accepted answer is nonsense.
      – chrylis
      Nov 7 at 19:13










    • The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
      – tsolakp
      Nov 7 at 19:50


















    • Why would JPA entities need to be serializable?
      – chrylis
      Nov 7 at 17:58










    • @chrylis stackoverflow.com/questions/2020904/…
      – tsolakp
      Nov 7 at 18:05










    • That question doesn't actually have any correct answers. The accepted answer is nonsense.
      – chrylis
      Nov 7 at 19:13










    • The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
      – tsolakp
      Nov 7 at 19:50
















    Why would JPA entities need to be serializable?
    – chrylis
    Nov 7 at 17:58




    Why would JPA entities need to be serializable?
    – chrylis
    Nov 7 at 17:58












    @chrylis stackoverflow.com/questions/2020904/…
    – tsolakp
    Nov 7 at 18:05




    @chrylis stackoverflow.com/questions/2020904/…
    – tsolakp
    Nov 7 at 18:05












    That question doesn't actually have any correct answers. The accepted answer is nonsense.
    – chrylis
    Nov 7 at 19:13




    That question doesn't actually have any correct answers. The accepted answer is nonsense.
    – chrylis
    Nov 7 at 19:13












    The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
    – tsolakp
    Nov 7 at 19:50




    The point of the link is not the accepted answer but fact that you can potentially run into not serializable entity exception with Hibernate and it has become a practice to mark JPA entities as serializable.
    – tsolakp
    Nov 7 at 19:50










    up vote
    0
    down vote



    accepted










    This might not be the correct answer, but so far in my case it matches and explains what I am seeing. I have not seen this information mentioned else where, but the answer is well upvoted, has been around for awhile, and is from a high reputation user, so I am inclined to trust it.



    There is an answer from another question where they mention something important.




    As to the why you need to worry about serialization, this is because most Java servlet containers like Tomcat require classes to implement Serializable whenever instances of those classes are been stored as an attribute of the HttpSession. That is because the HttpSession may need to be saved on the local disk file system or even transferred over network when the servlet container needs to shutdown/restart or is being placed in a cluster of servers wherein the session has to be synchronized.




    The application Im working on DOES use Tomcat, so if this is a restriction or behavior, then I can easily see why all the POJO's are created in this fashion, simply to avoid issues that might develop later, and is a result of experience having worked with this all before, and its that experience that I am lacking.






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      This might not be the correct answer, but so far in my case it matches and explains what I am seeing. I have not seen this information mentioned else where, but the answer is well upvoted, has been around for awhile, and is from a high reputation user, so I am inclined to trust it.



      There is an answer from another question where they mention something important.




      As to the why you need to worry about serialization, this is because most Java servlet containers like Tomcat require classes to implement Serializable whenever instances of those classes are been stored as an attribute of the HttpSession. That is because the HttpSession may need to be saved on the local disk file system or even transferred over network when the servlet container needs to shutdown/restart or is being placed in a cluster of servers wherein the session has to be synchronized.




      The application Im working on DOES use Tomcat, so if this is a restriction or behavior, then I can easily see why all the POJO's are created in this fashion, simply to avoid issues that might develop later, and is a result of experience having worked with this all before, and its that experience that I am lacking.






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        This might not be the correct answer, but so far in my case it matches and explains what I am seeing. I have not seen this information mentioned else where, but the answer is well upvoted, has been around for awhile, and is from a high reputation user, so I am inclined to trust it.



        There is an answer from another question where they mention something important.




        As to the why you need to worry about serialization, this is because most Java servlet containers like Tomcat require classes to implement Serializable whenever instances of those classes are been stored as an attribute of the HttpSession. That is because the HttpSession may need to be saved on the local disk file system or even transferred over network when the servlet container needs to shutdown/restart or is being placed in a cluster of servers wherein the session has to be synchronized.




        The application Im working on DOES use Tomcat, so if this is a restriction or behavior, then I can easily see why all the POJO's are created in this fashion, simply to avoid issues that might develop later, and is a result of experience having worked with this all before, and its that experience that I am lacking.






        share|improve this answer












        This might not be the correct answer, but so far in my case it matches and explains what I am seeing. I have not seen this information mentioned else where, but the answer is well upvoted, has been around for awhile, and is from a high reputation user, so I am inclined to trust it.



        There is an answer from another question where they mention something important.




        As to the why you need to worry about serialization, this is because most Java servlet containers like Tomcat require classes to implement Serializable whenever instances of those classes are been stored as an attribute of the HttpSession. That is because the HttpSession may need to be saved on the local disk file system or even transferred over network when the servlet container needs to shutdown/restart or is being placed in a cluster of servers wherein the session has to be synchronized.




        The application Im working on DOES use Tomcat, so if this is a restriction or behavior, then I can easily see why all the POJO's are created in this fashion, simply to avoid issues that might develop later, and is a result of experience having worked with this all before, and its that experience that I am lacking.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 19:23









        Fering

        1288




        1288






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194829%2fpojo-classes-being-serialized-with-no-read-write-usage%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini