LIAS Data Architecture Database Access Language
I wrote a small language that I use to generate the database access classes. At the moment, it's line-based ASCII. But, I should probably move it to an XML format sometime. Here's a small snippet:
class : Annotatable : annotatable
field : id : long : SERIAL annotatables_id_seq, UNIQUE, PRIMARY
field : type : int
field : created : java.sql.Timestamp
find : * : findByType( int _type ) : type = ${_type} ORDER BY id ASC
find : * : findAfter( java.sql.Timestamp _after ) : ${_after} <= created ORDER BY id ASC
find : * : findBefore( java.sql.Timestamp _before ) : created <= ${_before} ORDER BY id ASC
find : * : findBetween( java.sql.Timestamp _after, java.sql.Timestamp _before ) : ${_after} <= created AND created <= ${_before} ORDER BY id ASC
class : User : users : Annotatable
field : login : java.lang.String : VARCHAR 32, UNIQUE
field : password : java.lang.String : VARCHAR 32
field : realName : java.lang.String : VARCHAR 64
find : * : findByName( java.lang.String _nn ) : name LIKE ${_nn} ORDER BY id ASC
This snippet generates the following:
Annotatable class,
AnnotatableStore interface,
JDBCAnnotatableStore class that implements the interface through JDBC,
User class,
UserStore interface,
JDBCUserStore class that implements the interface through JDBC,
StoreFactory interface that is a factory for creating instances of the stores, and
JDBCStoreFactory class that is implements that interface for the JDBC store classes.
Here's what the
AnnotatableStore interface looks like:
package edu.rit.cis.larch;
public interface AnnotatableStore {
public edu.rit.cis.larch.Annotatable instance();
public boolean insert( edu.rit.cis.larch.Annotatable _dd );
public boolean update( edu.rit.cis.larch.Annotatable _dd );
public boolean delete( edu.rit.cis.larch.Annotatable _dd );
public edu.rit.cis.larch.Annotatable findById( long _id );
public java.util.Collection findByType( int _type );
public java.util.Collection findAfter( java.sql.Timestamp _after );
public java.util.Collection findBefore( java.sql.Timestamp _before );
public java.util.Collection findBetween( java.sql.Timestamp _after, java.sql
.Timestamp _before );
};
And, here's what the
UserStore interface looks like:
package edu.rit.cis.larch;
public interface UserStore extends edu.rit.cis.larch.AnnotatableStore {
public edu.rit.cis.larch.User findByLogin( java.lang.String _login );
public java.util.Collection findByName( java.lang.String _nn );
};
--
PatrickStein - 08 Aug 2005