Be careful with GSON. It by-passes your getter and setter.
That alone creates a bit of mismatch because JAXB (which is used by JAX-RS) uses getter/setter by default unless you specified it otherwise.
And sometime you do have some logic in your getter/setter for validation or other purposes.
I got bitten by this before while it seems like a small thing it's actually a bit problematic.
If you're using JPA2, take a look at Spring-Data (formerly Hades). Spring-Data helps you to reduce JPA boilerplate code.
The way Spring-Data works is by using a convention: specify your NamedQuery and a Java interface with method name == NamedQuery name. Then magic suddenly happens.
That alone creates a bit of mismatch because JAXB (which is used by JAX-RS) uses getter/setter by default unless you specified it otherwise.
And sometime you do have some logic in your getter/setter for validation or other purposes.
I got bitten by this before while it seems like a small thing it's actually a bit problematic.
If you're using JPA2, take a look at Spring-Data (formerly Hades). Spring-Data helps you to reduce JPA boilerplate code.
The way Spring-Data works is by using a convention: specify your NamedQuery and a Java interface with method name == NamedQuery name. Then magic suddenly happens.