Search in sources :

Example 1 with QuoteAdress

use of org.apache.cayenne.testdo.quotemap.QuoteAdress in project cayenne by apache.

the class QuotedIdentifiersIT method testPrefetchQuote.

@Test
public void testPrefetchQuote() {
    DbEntity entity = context.getEntityResolver().getObjEntity(QuoteAdress.class).getDbEntity();
    List<DbAttribute> idAttributes = Collections.singletonList(entity.getAttribute("City"));
    List<DbAttribute> updatedAttributes = Collections.singletonList(entity.getAttribute("City"));
    UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, Collections.emptySet(), 1);
    List objects3 = context.performQuery(updateQuery);
    assertEquals(0, objects3.size());
    List<Quote_Person> objects4 = ObjectSelect.query(Quote_Person.class).select(context);
    assertEquals(2, objects4.size());
    List<Quote_Person> objects5 = ObjectSelect.query(Quote_Person.class, Quote_Person.SALARY.eq(100)).select(context);
    assertEquals(1, objects5.size());
    List<Quote_Person> objects6 = ObjectSelect.query(Quote_Person.class, Quote_Person.GROUP.eq("107324")).select(context);
    assertEquals(1, objects6.size());
    List<QuoteAdress> objects7 = ObjectSelect.query(QuoteAdress.class, QuoteAdress.GROUP.eq("324")).select(context);
    assertEquals(1, objects7.size());
    ObjectIdQuery queryObjectId = new ObjectIdQuery(ObjectId.of("QuoteAdress", QuoteAdress.GROUP.getName(), "324"));
    List objects8 = context.performQuery(queryObjectId);
    assertEquals(1, objects8.size());
    ObjectIdQuery queryObjectId2 = new ObjectIdQuery(ObjectId.of("Quote_Person", "GROUP", "1111"));
    List objects9 = context.performQuery(queryObjectId2);
    assertEquals(1, objects9.size());
    Quote_Person quote_Person2 = ObjectSelect.query(Quote_Person.class, Quote_Person.NAME.eq("Name")).selectOne(context);
    RelationshipQuery relationshipQuery = new RelationshipQuery(quote_Person2.getObjectId(), "address_Rel");
    List objects10 = context.performQuery(relationshipQuery);
    assertEquals(1, objects10.size());
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) RelationshipQuery(org.apache.cayenne.query.RelationshipQuery) UpdateBatchQuery(org.apache.cayenne.query.UpdateBatchQuery) DbAttribute(org.apache.cayenne.map.DbAttribute) QuoteAdress(org.apache.cayenne.testdo.quotemap.QuoteAdress) List(java.util.List) Quote_Person(org.apache.cayenne.testdo.quotemap.Quote_Person) ObjectIdQuery(org.apache.cayenne.query.ObjectIdQuery) Test(org.junit.Test)

Example 2 with QuoteAdress

use of org.apache.cayenne.testdo.quotemap.QuoteAdress in project cayenne by apache.

the class QuotedIdentifiersIT method testInsert.

@Test
public void testInsert() {
    QuoteAdress quoteAdress = context.newObject(QuoteAdress.class);
    quoteAdress.setCity("city");
    quoteAdress.setGroup("324");
    Quote_Person quote_Person = context.newObject(Quote_Person.class);
    quote_Person.setSalary(10000);
    quote_Person.setName("Arcadi");
    quote_Person.setGroup("107324");
    quote_Person.setAddress_Rel(quoteAdress);
    context.commitChanges();
    QuoteAdress quoteAdress2 = context.newObject(QuoteAdress.class);
    quoteAdress2.setCity("city2");
    Quote_Person quote_Person2 = context.newObject(Quote_Person.class);
    quote_Person2.setSalary(100);
    quote_Person2.setName("Name");
    quote_Person2.setGroup("1111");
    quote_Person2.setDAte(new Date());
    quote_Person2.setAddress_Rel(quoteAdress2);
    context.commitChanges();
    List<QuoteAdress> objects = ObjectSelect.query(QuoteAdress.class).select(context);
    assertEquals(4, objects.size());
    List<Quote_Person> objects2 = ObjectSelect.query(Quote_Person.class).select(context);
    assertEquals(4, objects2.size());
}
Also used : QuoteAdress(org.apache.cayenne.testdo.quotemap.QuoteAdress) Quote_Person(org.apache.cayenne.testdo.quotemap.Quote_Person) Date(java.util.Date) Test(org.junit.Test)

Example 3 with QuoteAdress

use of org.apache.cayenne.testdo.quotemap.QuoteAdress in project cayenne by apache.

the class QuotedIdentifiersIT method setUp.

@Before
public void setUp() throws Exception {
    QuoteAdress quoteAdress = context.newObject(QuoteAdress.class);
    quoteAdress.setCity("city");
    quoteAdress.setGroup("324");
    Quote_Person quote_Person = context.newObject(Quote_Person.class);
    quote_Person.setSalary(10000);
    quote_Person.setName("Arcadi");
    quote_Person.setGroup("107324");
    quote_Person.setAddress_Rel(quoteAdress);
    context.commitChanges();
    QuoteAdress quoteAdress2 = context.newObject(QuoteAdress.class);
    quoteAdress2.setCity("city2");
    Quote_Person quote_Person2 = context.newObject(Quote_Person.class);
    quote_Person2.setSalary(100);
    quote_Person2.setName("Name");
    quote_Person2.setGroup("1111");
    quote_Person2.setDAte(new Date());
    quote_Person2.setAddress_Rel(quoteAdress2);
    context.commitChanges();
}
Also used : QuoteAdress(org.apache.cayenne.testdo.quotemap.QuoteAdress) Quote_Person(org.apache.cayenne.testdo.quotemap.Quote_Person) Date(java.util.Date) Before(org.junit.Before)

Aggregations

QuoteAdress (org.apache.cayenne.testdo.quotemap.QuoteAdress)3 Quote_Person (org.apache.cayenne.testdo.quotemap.Quote_Person)3 Date (java.util.Date)2 Test (org.junit.Test)2 List (java.util.List)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbEntity (org.apache.cayenne.map.DbEntity)1 ObjectIdQuery (org.apache.cayenne.query.ObjectIdQuery)1 RelationshipQuery (org.apache.cayenne.query.RelationshipQuery)1 UpdateBatchQuery (org.apache.cayenne.query.UpdateBatchQuery)1 Before (org.junit.Before)1