r2 - 11 Jun 2006 - 23:56:59 - BobKrzaczekYou are here: TWiki >  LIAS Web  >  ProjectDiary > LarchDBAcessLang
Tags:
create new tag
, view all tags

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

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback