source: trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java @ 28

Last change on this file since 28 was 28, checked in by fmguler, 13 years ago

Refs #3 - Ven.get() is converted to the new format. QueryGenerator and QueryMapper are mostly OK, generateRecursively and mapRecursively are converted and checked. Handles joins (includes/associations) many to one and one to many. For one to many, the reverse join field can be determined in a couple of ways. First way is (prefereed) having VenList as the list implementation which specifies the element class and the join field. Second way is using Java 1.5 generic type to detect element class (not yet implemented) and guessing join field by convention (if multiple joins exist, this won't work). The last way is to have some kind of annotation or configuration, which is of course the least preferred way. VenList has a static method to determine the element class in the object list, which currently calls getElementClass if the list is an instance of VenList. In the future other options can be implemented.

Getting object using joins (includes/associations) are tested using dummy assocations between SomeDomainObject and AnotherDomainObject. The Sample class builds the database, tests the operations and rolls back to the initial state. Database refactoring operations are moved to the LiquibaseUtil for clarity.

In the future, the generated queries will be shortened using hashed aliases, and the criteria subsystem will be implemented.

File size: 2.9 KB
Line 
1/*
2 *  fmgVen - A Convention over Configuration Java ORM Tool
3 *  Copyright 2010 Fatih Mehmet Güler
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *  under the License.
17 */
18package com.fmguler.ven.sample.domain;
19
20import com.fmguler.ven.util.VenList;
21import java.util.Date;
22import java.util.List;
23
24/**
25 *
26 * @author Fatih Mehmet Güler
27 */
28public class SomeDomainObject {
29    private Integer id;
30    private String name;
31    private String description;
32    private Date date;
33    private List anotherDomainObjects = new VenList(AnotherDomainObject.class, "someDomainObject");
34    private AnotherDomainObject anotherDomainObject = new AnotherDomainObject();
35
36    /**
37     * @return the id
38     */
39    public Integer getId() {
40        return id;
41    }
42
43    /**
44     * @param id the id to set
45     */
46    public void setId(Integer id) {
47        this.id = id;
48    }
49
50    /**
51     * @return the name
52     */
53    public String getName() {
54        return name;
55    }
56
57    /**
58     * @param name the name to set
59     */
60    public void setName(String name) {
61        this.name = name;
62    }
63
64    /**
65     * @return the description
66     */
67    public String getDescription() {
68        return description;
69    }
70
71    /**
72     * @param description the description to set
73     */
74    public void setDescription(String description) {
75        this.description = description;
76    }
77
78    /**
79     * @return the date
80     */
81    public Date getDate() {
82        return date;
83    }
84
85    /**
86     * @param date the date to set
87     */
88    public void setDate(Date date) {
89        this.date = date;
90    }
91
92    /**
93     * @return the list of AnotherDomainObject
94     */
95    public List getAnotherDomainObjects() {
96        return anotherDomainObjects;
97    }
98
99    /**
100     * @return the anotherDomainObject
101     */
102    public AnotherDomainObject getAnotherDomainObject() {
103        return anotherDomainObject;
104    }
105
106    /**
107     * @param anotherDomainObject the anotherDomainObject to set
108     */
109    public void setAnotherDomainObject(AnotherDomainObject anotherDomainObject) {
110        this.anotherDomainObject = anotherDomainObject;
111    }
112
113    public String toString() {
114        return id + " " + name + " " + description + " another domain object: {" + anotherDomainObject + "} another domain objects:\n" + anotherDomainObjects;
115    }
116}
Note: See TracBrowser for help on using the repository browser.