mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
moved all domain types of HqlParserTest into one java file
This commit is contained in:
parent
7ae47ae9d7
commit
e2e444c418
@ -95,7 +95,7 @@
|
||||
-AdtoClass=com.mysema.query.Domain1Dtos
|
||||
</A>
|
||||
<testIncludes>
|
||||
<testInclude>com/mysema/query/grammar/hql/domain/*.java</testInclude>
|
||||
<testInclude>com/mysema/query/grammar/hql/*.java</testInclude>
|
||||
</testIncludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@ -16,6 +16,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.grammar.PathMetadata;
|
||||
import com.mysema.query.grammar.Types.ExprBoolean;
|
||||
import com.mysema.query.grammar.Types.PathEntity;
|
||||
import com.mysema.query.grammar.Types.PathNoEntitySimple;
|
||||
@ -33,7 +34,7 @@ public class HqlQuery extends HqlQueryBase<HqlQuery>{
|
||||
|
||||
private Integer limit, offset;
|
||||
|
||||
private Session session;
|
||||
private final Session session;
|
||||
|
||||
public HqlQuery(Session session) {
|
||||
this.session = session;
|
||||
@ -67,7 +68,8 @@ public class HqlQuery extends HqlQueryBase<HqlQuery>{
|
||||
&& !entry.getKey().equals("class")
|
||||
&& !entry.getKey().equals("created")
|
||||
&& !entry.getKey().equals("modified")){
|
||||
PathNoEntitySimple path = new PathNoEntitySimple(Object.class, entity, entry.getKey());
|
||||
PathMetadata md = PathMetadata.forProperty(entity, entry.getKey());
|
||||
PathNoEntitySimple path = new PathNoEntitySimple(Object.class, md);
|
||||
if (entry.getValue() != null){
|
||||
conds.add(path.eq(entry.getValue()));
|
||||
}else{
|
||||
|
||||
@ -10,14 +10,11 @@ import static com.mysema.query.grammar.Grammar.mult;
|
||||
import static com.mysema.query.grammar.Grammar.not;
|
||||
import static com.mysema.query.grammar.Grammar.sub;
|
||||
import static com.mysema.query.grammar.HqlGrammar.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.Domain1.Company;
|
||||
import com.mysema.query.Domain1.Department;
|
||||
import com.mysema.query.Domain1.Employee;
|
||||
import com.mysema.query.grammar.HqlGrammar;
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.grammar.HqlSerializer;
|
||||
@ -113,8 +110,8 @@ public class FeaturesTest extends HqlQueryBase<FeaturesTest>{
|
||||
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
Constructor<com.mysema.query.grammar.hql.domain.Cat> c = new Constructor<com.mysema.query.grammar.hql.domain.Cat>(com.mysema.query.grammar.hql.domain.Cat.class, cat.name);
|
||||
toString("new com.mysema.query.grammar.hql.domain.Cat(cat.name)", c);
|
||||
Constructor<com.mysema.query.grammar.hql.HqlDomain.Cat> c = new Constructor<com.mysema.query.grammar.hql.HqlDomain.Cat>(com.mysema.query.grammar.hql.HqlDomain.Cat.class, cat.name);
|
||||
toString("new "+com.mysema.query.grammar.hql.HqlDomain.Cat.class.getName()+"(cat.name)", c);
|
||||
toString("new "+getClass().getName()+"$BookmarkDTO()", new _BookmarkDTO());
|
||||
toString("new "+getClass().getName()+"$BookmarkDTO(cat.name)", new _BookmarkDTO(cat.name));
|
||||
}
|
||||
@ -220,18 +217,6 @@ public class FeaturesTest extends HqlQueryBase<FeaturesTest>{
|
||||
}
|
||||
|
||||
// "Simple" case, case ... when ... then ... else ... end, and "searched" case, case when ... then ... else ... end
|
||||
|
||||
|
||||
@Test
|
||||
public void testShortCuts(){
|
||||
Company c = new Company("c");
|
||||
Department d = new Department("d");
|
||||
Employee e = new Employee("e");
|
||||
// select(c.name, d.name, e.firstName, e.lastName).from(c.join().departments.as(d).join().employees.as(e));
|
||||
// join -> PathEntityRelations (foreign key fields)
|
||||
// departments -> PathEntityRelations
|
||||
// as(d) -> sets alias
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAliasForNonEntityPaths(){
|
||||
|
||||
@ -16,9 +16,9 @@ import antlr.collections.AST;
|
||||
import com.mysema.query.Domain1;
|
||||
import com.mysema.query.Domain1Dtos;
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.grammar.hql.domain.Color;
|
||||
import com.mysema.query.grammar.hql.domain.DomesticCat;
|
||||
import com.mysema.query.grammar.hql.domain.Payment;
|
||||
import com.mysema.query.grammar.hql.HqlDomain.Color;
|
||||
import com.mysema.query.grammar.hql.HqlDomain.DomesticCat;
|
||||
import com.mysema.query.grammar.hql.HqlDomain.Payment;
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ public class HqlParserTest extends HqlQueryBase<HqlParserTest>{
|
||||
private Domain1.Calendar calendar = new Domain1.Calendar("calendar");
|
||||
|
||||
private Domain1.Cat cat = new Domain1.Cat("cat");
|
||||
private Domain1.Cat fatcat = new Domain1.Cat("fatcat");
|
||||
// private Domain1.Cat fatcat = new Domain1.Cat("fatcat");
|
||||
private Domain1.Cat kittens = new Domain1.Cat("kittens");
|
||||
private Domain1.Cat kitten = new Domain1.Cat("kitten");
|
||||
private Domain1.Cat kit = new Domain1.Cat("kit");
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Account provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Account {
|
||||
Person owner;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Animal provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Animal {
|
||||
int bodyWeight, id, weight, toes;
|
||||
String name;
|
||||
Color color;
|
||||
boolean alive;
|
||||
java.util.Date birthdate;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* AuditLog provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class AuditLog {
|
||||
Item item;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Bar provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Bar {
|
||||
java.util.Date date;
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Calendar provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Calendar {
|
||||
Map<String,java.util.Date> holidays;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Cat provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Cat extends Animal{
|
||||
Collection<Cat> kittens;
|
||||
Cat mate;
|
||||
Color eyecolor;
|
||||
int breed;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Catalog provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Catalog {
|
||||
Collection<Price> prices;
|
||||
Date effectiveDate;
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
/**
|
||||
* Color provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public enum Color {
|
||||
BLACK, TABBY
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
|
||||
/**
|
||||
* Company provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Company {
|
||||
long id;
|
||||
String name;
|
||||
List<Department> departments;
|
||||
Employee ceo;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Customer provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Customer {
|
||||
Name name;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Department provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Department {
|
||||
String name;
|
||||
Company company;
|
||||
List<Employee> employees;
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Document provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Document {
|
||||
String name;
|
||||
Date validTo;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* DomesticCat provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class DomesticCat extends Cat{
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Employee provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Employee {
|
||||
String firstName, lastName;
|
||||
Company company;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* EvilType provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class EvilType {
|
||||
EvilType isnull, isnotnull, asc, desc, get, getType, getMetadata;
|
||||
EvilType toString, hashCode, getClass, notify, notifyAll, wait;
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import com.mysema.query.dto.DTO;
|
||||
|
||||
/**
|
||||
* Family provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@DTO
|
||||
public class Family {
|
||||
public Family(Cat mother, Cat mate, Cat offspr){
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import com.mysema.query.dto.DTO;
|
||||
|
||||
/**
|
||||
* Foo provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
@DTO
|
||||
public class Foo {
|
||||
java.util.Date startDate;
|
||||
String bar;
|
||||
public Foo(){}
|
||||
public Foo(long l){}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Formula provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Formula {
|
||||
Parameter parameter;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Item provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Item {
|
||||
long id;
|
||||
Product product;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Location provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Location {
|
||||
String name;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Name provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Name {
|
||||
String firstName, lastName;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Named provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Named {
|
||||
String name;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Nationality provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Nationality {
|
||||
Calendar calendar;
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Order provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Order {
|
||||
long id;
|
||||
List<Item> items, lineItems;
|
||||
List<Integer> deliveredItemIndices;
|
||||
boolean paid;
|
||||
Customer customer;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Parameter provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Parameter {
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Payment provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Payment extends Item{
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Person provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Person {
|
||||
PersonId id;
|
||||
Nationality nationality;
|
||||
java.util.Date birthDay;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* PersonId provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class PersonId {
|
||||
String country;
|
||||
int medicareNumber;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Price provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Price {
|
||||
long amount;
|
||||
Product product;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Product provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Product {
|
||||
String name;
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* Store provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class Store {
|
||||
List<Customer> customers;
|
||||
Location location;
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.mysema.query.grammar.hql.domain;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
|
||||
/**
|
||||
* User provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
@Entity
|
||||
public class User {
|
||||
Company company;
|
||||
long id;
|
||||
String userName, firstName, lastName;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user