Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to mark a field as not to be expanded by JAXB in JAXRS
    primarykey
    data
    text
    <p>I have 2 classes as follows:</p> <pre><code>@XmlRootElement @PersistenceCapable(detachable="true") public class User { @Persistent(primaryKey="true", valueStrategy=IdGeneratorStrategy.IDENTITY) private Long id; private String firstname; private String lastname; private UserDetails userDetails; ... } </code></pre> <p>and</p> <pre><code>@XmlRootElement @PersistenceCapable(detachable="true") public class UserDetails { private String streetaddress; private String address; private String city; private int pincode; private Date dateofbirth; ... } </code></pre> <p>I need to retrieve the user objects only, without having the userdetails in one JAXRS function, and both the user object and its attached userdetails object in another as shown.</p> <pre><code>//UserManager.java public List&lt;User&gt; getUsers() { javax.jdo.Query q = pm.newQuery("SELECT FROM "+ User.class.getName()); List&lt;User&gt; users = (List&lt;User&gt;) q.execute(); return users; } </code></pre> <p>and the JAXRS service:</p> <pre><code>@GET @Produces({MediaType.APPLICATION_JSON}) public List&lt;User&gt; getUsers() { //Retrieves all users and user details UserManager um=new UserManager(); //working perfectly return um.getUsers(); } @GET @Produces({MediaType.APPLICATION_JSON}) public List&lt;User&gt; getUsers() { //should retrieve user only, but how? UserManager um=new UserManager(); return ????? } </code></pre> <p>How can I prevent the UserDetails object from being expanded by JAXRS and JAXB for the second function???</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload