QueryJ meta-language
Table of Contents
As you may already know, the main development of QueryJ is right now being pushed by Ventura24 requirements.
We are including more features as soon as we find nice-to-haves. First, the query validation, the customization of templates to make Spring be aware of heterogeneous transactions (Connection/DataSource), some performance improvements, and so on.
Lately I made QueryJ support a dsl to support logical statements as part of the comments of the physical table model. So far, the following statements are interpreted:
Table-related
- static column-name
Used to improve performance by avoiding the need to access the database to operate on certain static tables, such as typecodes. This keyword makes QueryJ generate constants in the Java side with the contents of the table, at development time. The column-name is used to build the constant name.
- @isa parent-table
Identifies the table as a child of given one. This means it inherits parent's attributes and relationships, besides its own.
- @isatype type-table
For a parent table in an ISA relationship, it indicates which additional table is used to specify all possible children. That is generally not needed in practice, but makes the ISA more clear and self-explanatory.
- @decorator
Indicates all DAO operations will use a decorator instead of a plain ValueObject. This is useful in refactorings, in which you had a ValueObject with a number of attributes (since its associated table was pretty wide), and you change it to use a metadata table(s) for the optional ones, so you can add more in the future without DDL changes. In such case, the API for the ValueObject changes, but you can make it appear as if it were the same, by using decorators. Since this kind of refactoring changes the API significantly, you'd end up with a lot of compile errors throughout all client code. Using @decorator allows you to reduce such errors by changing ValueObject to ValueObjectDecorator, and writing (and caching) logic for retrieving the missing attributes via DAO calls.
- @relationship (foreign-key1),(foreign-key2)
This indicates to QueryJ that the table is an implementation of a many-to-many relationship, and that it makes no sense to build DAO or ValueObject for it.
Column-related
- @readonly
It's used to indicate that the column is managed completely at the database side, and that it cannot be modified from the application. This is usually the case of last-modified or creation-date helper attributes: you don't want/need them to be parameters in Java by any means. With this keyword, you can access them, but you're never supposed to specify them.
- @bool trueValue,falseValue[,nullValue]
Denotes a column is a boolean value, regardless of its declared type. QueryJ declares it as boolean in the Java side, and transforms its value to given constants when accessing the database. In case the column is not nullable, and you want to be able to work with null values in the application, you'd then specify also the value to represent nulls.
- @isarefs (value1, child-table1) ... (valueN, child-tableN)
For static tables used as helpers of ISA relationships, this keyword can be used in the actual attribute that enumerates all possible ISA children. That will be used in the future to improve ISA support by omitting redundant information from the child tables. This only makes sense in tables referred by ISA parents via @isatype keyword.
- @oraseq sequence
This keyword attaches an Oracle sequence to a concrete attribute.
For more information, please take a look at the ANTLR grammar.
Enjoy!

rss
Comments
No comments.