use of org.apache.cayenne.testdo.quotemap.Quote_Person in project cayenne by apache.
the class QuotedIdentifiersIT method testPrefetchQuote.
@Test
public void testPrefetchQuote() throws Exception {
DbEntity entity = context.getEntityResolver().getObjEntity(QuoteAdress.class).getDbEntity();
List idAttributes = Collections.singletonList(entity.getAttribute("City"));
List updatedAttributes = Collections.singletonList(entity.getAttribute("City"));
UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, Collections.<String>emptySet(), 1);
List objects3 = context.performQuery(updateQuery);
assertEquals(0, objects3.size());
SelectQuery qQuote_Person2 = new SelectQuery(Quote_Person.class);
List objects4 = context.performQuery(qQuote_Person2);
assertEquals(2, objects4.size());
SelectQuery qQuote_Person3 = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("salary", 100));
List objects5 = context.performQuery(qQuote_Person3);
assertEquals(1, objects5.size());
SelectQuery qQuote_Person4 = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("group", "107324"));
List objects6 = context.performQuery(qQuote_Person4);
assertEquals(1, objects6.size());
SelectQuery quoteAdress1 = new SelectQuery(QuoteAdress.class, ExpressionFactory.matchExp("group", "324"));
List objects7 = context.performQuery(quoteAdress1);
assertEquals(1, objects7.size());
ObjectIdQuery queryObjectId = new ObjectIdQuery(new ObjectId("QuoteAdress", QuoteAdress.GROUP.getName(), "324"));
List objects8 = context.performQuery(queryObjectId);
assertEquals(1, objects8.size());
ObjectIdQuery queryObjectId2 = new ObjectIdQuery(new ObjectId("Quote_Person", "GROUP", "1111"));
List objects9 = context.performQuery(queryObjectId2);
assertEquals(1, objects9.size());
SelectQuery person2Query = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("name", "Name"));
Quote_Person quote_Person2 = (Quote_Person) context.performQuery(person2Query).get(0);
RelationshipQuery relationshipQuery = new RelationshipQuery(quote_Person2.getObjectId(), "address_Rel");
List objects10 = context.performQuery(relationshipQuery);
assertEquals(1, objects10.size());
}
use of org.apache.cayenne.testdo.quotemap.Quote_Person in project cayenne by apache.
the class QuotedIdentifiersIT method testQuotedEJBQLQueryWithOrderBy.
@Test
public void testQuotedEJBQLQueryWithOrderBy() throws Exception {
EJBQLQuery query = new EJBQLQuery("select p from Quote_Person p order by p.name");
List<Quote_Person> resultList = (List<Quote_Person>) context.performQuery(query);
assertEquals(2, resultList.size());
assertEquals("Arcadi", resultList.get(0).getName());
assertEquals("Name", resultList.get(1).getName());
}
use of org.apache.cayenne.testdo.quotemap.Quote_Person 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();
SelectQuery q = new SelectQuery(QuoteAdress.class);
List objects = context.performQuery(q);
assertEquals(1, objects.size());
SelectQuery qQuote_Person = new SelectQuery(Quote_Person.class);
List objects2 = context.performQuery(qQuote_Person);
assertEquals(1, objects2.size());
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();
}
Aggregations