3

Basically I am in the process of evaluating thrift for an upcoming project. What I am trying to achieve is to have my data layer written in Java which then serves (via thrift) a ror powered website as well as an iPhone application.
I have familiarised myseld with thrift's IDL and it seems a strong contender due to its efficiencies versus a RESTful service.
I would like to send the POJO via thrift however to do so I am currently having to convert the POJO to the thrift generated object before it can be used by the thrift service however I can't stop feeling there is a better way of doing this which doesn't involve having to do the conversion. Are there any best practises to overcome this problem?

If you need any more specific information please let me know.

luxerama
  • 1,109
  • 2
  • 14
  • 31

2 Answers2

3

Swift can also do this - you can annotate your POJOs with both JPA and Swift annotations, then use Swift+Thrift to serialize them. Swift can generate Thrift IDL from the annotated classes for you to use elsewhere.

This is Swift: https://github.com/facebook/swift/

Alex Hayward
  • 216
  • 1
  • 4
  • How does this approach handle serializing things like hibernate's Pageable class? (Since I can't add Swift annotations to this). – user48956 Dec 02 '14 at 16:54
1

I think the best way is to implement the thrift IDL properly and map your structs against a hbm.xml. This way you can generate your POJO's throught thrift compiler, and can persist'em using hibernate.

mannysz
  • 951
  • 8
  • 19
  • 1
    I did something similar, I extended the Hibernate POJOs from the generated thrift objects which can then be casted to the correct type when needed. – luxerama Feb 24 '12 at 11:41