Tabnine Logo
PojoRepositoryImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
PojoRepositoryImpl
in
com.marklogic.client.impl

Best Java code snippets using com.marklogic.client.impl.PojoRepositoryImpl (Showing top 18 results out of 315)

origin: marklogic/java-client-api

@Override
public <T, ID extends Serializable> PojoRepository<T, ID> newPojoRepository(Class<T> clazz, Class<ID> idClass) {
 return new PojoRepositoryImpl<>(this, clazz, idClass);
}
origin: marklogic/java-client-api

@Override
public long count(Transaction transaction) {
 return count((PojoQueryDefinition) null, transaction);
}
origin: marklogic/java-client-api

@Override
public String getDocumentUri(T entity) {
 return createUri(getId(entity));
}
origin: marklogic/java-client-api

@Override
public void write(T entity, Transaction transaction, String... collections) {
 if ( entity == null ) return;
 JacksonDatabindHandle<T> contentHandle = new JacksonDatabindHandle<>(entity);
 contentHandle.setMapper(objectMapper);
 DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
 metadataHandle = metadataHandle.withCollections(entityClass.getName());
 if ( collections != null && collections.length > 0 ) {
  metadataHandle = metadataHandle.withCollections(collections);
 }
 DocumentWriteSet writeSet = docMgr.newWriteSet();
 writeSet.add(getDocumentUri(entity), metadataHandle, contentHandle);
 try {
  docMgr.write(writeSet, transaction);
 } catch(MarkLogicIOException e) {
  checkForEmptyBeans(e);
  throw e;
 }
}
origin: marklogic/java-client-api

@Override
public void delete(ID[] ids, Transaction transaction) {
 for ( ID id : ids ) {
  docMgr.delete(createUri(id), transaction);
 }
}
origin: marklogic/java-client-api

PojoRepositoryImpl(DatabaseClient client, Class<T> entityClass, Class<ID> idClass) {
 this(client, entityClass);
 this.idClass = idClass;
 findId();
 if ( idMethod == null && idProperty == null ) {
  throw new IllegalArgumentException("Your class " + entityClass.getName() +
   " does not have a method or field annotated with com.marklogic.client.pojo.annotation.Id");
 }
}
origin: marklogic/java-client-api

@Override
public void delete(ID... ids) {
 delete(ids, null);
}
origin: marklogic/java-client-api

@Override
public void deleteAll() {
 deleteAll(null);
}
origin: marklogic/java-client-api

private void checkForEmptyBeans(Throwable e) {
 Throwable cause = e.getCause();
 if ( cause != null ) {
  if ( cause instanceof JsonMappingException &&
   cause.getMessage() != null &&
   cause.getMessage().contains("SerializationFeature.FAIL_ON_EMPTY_BEANS") )
  {
   throw new MarkLogicBindingException(
    "Each of your pojo beans and descendent beans must have public fields or paired get/set methods",
    cause);
  } else {
   checkForEmptyBeans(cause);
  }
 }
}
origin: marklogic/java-client-api

@Test
public void testIssue_93() throws Exception {
 PojoRepository<Student,Long> students = Common.client.newPojoRepository(Student.class, Long.class);
 long id=1;
 Student stud = new Student();
 stud.setName("Student1");
 stud.setStudId(id);
 Address adr = new Address();
 adr.setCountry("USA");
 adr.setState("CA");
 adr.setZip(94070);
 adr.setStreetName("1 tassman");
 stud.setAddress(adr);
 stud.setEmailId("stud@gmail.com");
 stud.setPhone(6602345);
 stud.setNationality("Indian");
 stud.setclassStatus(std_status.junior);
 @SuppressWarnings("rawtypes")
 ObjectMapper objectMapper = ((PojoRepositoryImpl) students).getObjectMapper();
 String value = objectMapper.writeValueAsString(stud);
 objectMapper.readValue(value, Student.class);
 students.write(stud, "students");
 Student student1 = students.read(id);
 assertEquals("Student id", student1.getStudId(), stud.getStudId());
 assertEquals("Zip code", student1.getAddress().zip, stud.getAddress().zip);
 assertEquals("class status", student1.getclassStatus(), stud.getclassStatus());
}
origin: marklogic/java-client-api

@Override
public boolean exists(ID id) {
 return docMgr.exists(createUri(id)) != null;
}
origin: marklogic/java-client-api

 @SuppressWarnings("unchecked")
 public ID getId(T entity) {
  findId();
  if ( idMethod != null ) {
   try {
    return (ID) idMethod.invoke(entity);
   } catch (Exception e) {
    throw new IllegalStateException("Error invoking " + entityClass.getName() + " method " +
     idMethod.getName(), e);
   }
  } else if ( idProperty != null ) {
   try {
    return (ID) idProperty.get(entity);
   } catch (Exception e) {
    throw new IllegalStateException("Error retrieving " + entityClass.getName() + " field " +
     idProperty.getName(), e);
   }
  } else {
   throw new IllegalArgumentException("Your class " + entityClass.getName() +
    " does not have a method or field annotated with com.marklogic.client.pojo.annotation.Id");
  }
 }
}
origin: marklogic/java-client-api

@Override
public long count(String... collections) {
 return count(collections, null);
}
origin: marklogic/java-client-api

@Override
public boolean exists(ID id, Transaction transaction) {
 return docMgr.exists(createUri(id), transaction) != null;
}
origin: marklogic/java-client-api

@Override
public long count() {
 return count((PojoQueryDefinition) null, null);
}
origin: marklogic/java-client-api

@Override
public PojoPage<T> read(ID[] ids, Transaction transaction) {
 List<String> uris = new ArrayList<>();
 for ( ID id : ids ) {
  uris.add(createUri(id));
 }
 DocumentPage docPage = (DocumentPage) docMgr.read(transaction, uris.toArray(new String[0]));
 PojoPage<T> pojoPage = new PojoPageImpl<>(docPage, entityClass);
 return pojoPage;
}
@Override
origin: marklogic/java-client-api

@Override
public long count(PojoQueryDefinition query) {
 return count((PojoQueryDefinition) query, null);
}
origin: marklogic/java-client-api

@Override
public long count(String[] collections, Transaction transaction) {
 if ( collections != null && collections.length > 0 ) {
  if ( collections.length > 1 || collections[0] != null ) {
   return count(qb.collection(collections), transaction);
  }
 }
 return count((PojoQueryDefinition) null, transaction);
}
com.marklogic.client.implPojoRepositoryImpl

Most used methods

  • <init>
  • checkForEmptyBeans
  • count
  • createUri
  • delete
  • deleteAll
  • findId
  • getDocumentUri
  • getId
  • getObjectMapper
  • getPageLength
  • read
  • getPageLength,
  • read,
  • search,
  • setPageLength,
  • wrapQuery,
  • write

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • getResourceAsStream (ClassLoader)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Permission (java.security)
    Legacy security code; do not use.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now