search - Listing/searching/paginating over documents using Marklogic's Java API and JAXB -


i'm learning how use marklogic 6 via java api , i'd find out how search/list/paginate through documents within java , jaxb. specifically:

suppose have set of user documents so:

/user/joe453.xml /user/karla47.xml . . . /user/sam.xml /user/tom.xml 

and user defined this:

<user userid="aaabbb123" passwordhash="bcrypthash">     <role id="user"> <--- other role types here depending on kind of user. </user> 

i know key/value based search if wanted search specific user on userid attribute. however:

1) functionality of java api should use to, in simplest case, list/paginate on these users?

2) know ad hoc xquery using xcc learned bad lessons last time used hardcoded query strings in sql. can see similar fate xml/marklogic.

3) there better way this?

thanks!

dat silencer:

to have search return entire documents, can set query options return entire document snippet:

<transform-results apply="raw"/> 

then, on client, can pass contents of search results persisted jaxb through jaxb unmarshaller hydrate java objects.

as alternative, java api includes searchcollector example, returns multipart / mixed payload each part search result document. documents persisted via jaxb can unmarshalled.

specifics aside, general strategy quite sensible -- take advantage of marklogic search fetch persisted objects of interest using field of object or subject.

the primary key, of course, still has value direct access. is, if object has combination of fields correspond immutably identity of entity, take advantage of fields make document uri , use direct access object when search overkill.