Announcement Announcement Module
Collapse
No announcement yet.
<var> - @Service - @Repository - Serialization problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <var> - @Service - @Repository - Serialization problem

    Hi all,

    I have read the below statement on http://www.springframework.org/node/604

    @Autowired flow variables. Flow variables may now have their dependencies @Autowired by Spring, enabling them to hold references to Spring-managed @Services. References to services are automatically re-wired for you between requests after variable deserialization.
    I have tried it out and autowired a Service Bean to one of my flow beans. My Service Bean has references to my DAOs and SWF tries to serialize
    Flowbean->Service Bean->Dao->"some stuff which can't and shouldnt be serialized".

    Can I avoid to serialize my DAOs? In case of yes what would be the impact?

    Thanks for any comments in advance.

    - Peter

  • #2
    it was my problem also

    check my thread...
    there is some options
    1-make your DAO serializable
    OR
    2- make the dao field transient
    make sure where to put the @Transactional annotation if u r using it
    OR better the swf team give us a formal statment

    Comment


    • #3
      Thanks for your reply.

      check my thread...
      I think I know which thread you mean but I have not read a real solution there (the one were Keith asks you why you try to serialize....)

      there is some options
      1-make your DAO serializable
      This does not work because afterwards SWF tries to serialize some Hibernate specific objects.

      2- make the dao field transient
      I have tried the @Transient annotation but with no effect.

      - Peter

      Comment


      • #4
        actually u can make ur DAO serializable if u r using a spring injected entityManager or session as they do not provide u with a real one but only a proxy which is lightweight in serialization

        if u wanna make it transient
        donot use @Transient annotation ,this is JPA specific,which tell jpa not to persist the annotated field in the database,use the transient keyword instead ,which tell java serializer not to serialize the field as follow

        transient private ModelDAO dao;
        that's said , i hope SWF team provide us a better solution or pattern
        joe

        Comment


        • #5
          A flow variable must be Serializable. If the flow variable has references to non-serializable objects, those references must be marked as transient (using the language keyword not the persistent annotation). If those references are marked as transient and are @Autowired, Spring Web Flow should care for restoring their values from the Spring BeanFactory before the variable is used - even between web requests.

          Keith

          Comment


          • #6
            Thanks a lot for the replies!

            Comment


            • #7
              Originally posted by Keith Donald View Post
              A flow variable must be Serializable. If the flow variable has references to non-serializable objects, those references must be marked as transient (using the language keyword not the persistent annotation). If those references are marked as transient and are @Autowired, Spring Web Flow should care for restoring their values from the Spring BeanFactory before the variable is used - even between web requests.

              Keith
              Hello Keith,
              do I have to use only annotated @Autowired option or may I can use autowire="byName" at the bean definition?
              Thanks
              Max

              Comment

              Working...
              X