Results 1 to 7 of 7

Thread: <var> - @Service - @Repository - Serialization problem

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    170

    Default <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. #2
    Join Date
    May 2008
    Posts
    227

    Default 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

  3. #3
    Join Date
    Mar 2008
    Posts
    170

    Default

    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

  4. #4
    Join Date
    May 2008
    Posts
    227

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    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
    Keith Donald
    Core Spring Development Team

  6. #6
    Join Date
    Mar 2008
    Posts
    170

    Default

    Thanks a lot for the replies!

  7. #7
    Join Date
    Jun 2011
    Posts
    2

    Default

    Quote 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •