java - Using Web Service Client JAXB Generated Classes as JPA Entities -


i working on project retrieve data soap webservice , store in database later use using jpa. presently, using spring ws client, , generating web service classes using jaxb.

the goal replicate of data contained in these classes (which rather large) faithfully in database, , end mildly tempting apply jpa annotations jaxb generated classes. in long run seems dangerous, because generated classes seem rather ephemeral, , lot of work re-applying jpa annotations while regenerating code if wsdl ever changed.

the other option have webservice client copy data jpa entities created me, possibly using factory pattern. decouples jpa persistence possibly changing whims of wsdl designer, , somehow feels safer. feels safer because entity classes can never overwritten build task.

what best practice situation? obviously, excessive decoupling not pay off when means lots of data transfer objects, case special? should jaxb created classes used in webservice client, , forgotten higher level application?

as principle not change objects generated jaxb. rightly pointed out you, these change every minor change wsdl.

the accepted process decouple jaxb objects , jpa entities. there 2 primary advantages of same

  1. you can change data binding provider @ later point of time if feel jaxb slow or memory intensive
  2. you not tying jpa code db code. if tomorrow wsdl changes or db structure changes either of these not impacted.

to transfer data between 2 can use factory pattern or use bean mapping framework

  1. dozer
  2. orika
  3. other options

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -