You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "xialvjun (JIRA)" <ji...@apache.org> on 2015/06/01 06:59:17 UTC

[jira] [Created] (METAMODEL-147) API, Maven CodeGenerator

xialvjun created METAMODEL-147:
----------------------------------

             Summary: API, Maven CodeGenerator
                 Key: METAMODEL-147
                 URL: https://issues.apache.org/jira/browse/METAMODEL-147
             Project: Apache MetaModel
          Issue Type: Wish
    Affects Versions: 4.4.0
            Reporter: xialvjun


I sended an email to dev@metamodel.apache.org last night.  But now I found jira site of metamodel, so paste the email here.

I've searched http://wiki.apache.org/metamodel/ with keyword "subquery", but there is no result.

I used to think if org.apache.metamodel.query.Query implements org.apache.metamodel.schema.Table  so I can do it like dataContext.query().from(query), but it doesn't. 

So I ask you how to do SubQuery in MetaModel.


In fact, I think the api of MetaModel can do a big change, like this:
{code}
TableLike = dataContext.query().from(TableLike... tables)

TableLike = dataContext.query().from(TableLike... tables).select(ColumnLike... columns)

Filter = ColumnLike.operator(value)
dataContext.query().from(TableLike... tables).select(ColumnLike... columns).where(Filter... filters).groupBy(ColumnLike... columns)

DataSet ds = TableLike.execute();
{code}

There are 3 main interfaces: TableLike , ColumnLike , Filter.

query, table, view are all TableLike;
column in a query, column in a table are all ColumnLike;
filter is generated by ColumnLike...

And if the Column Type can be represent by the class of Column, things may be better.
Maybe we can't make Column a generic class like Column<Integer>, because we can't use it like Column<Person>(wait, wait, wait, maybe we can if Person is just a java bean.... WOW, so it seems that TableLike is in fact a subclass of ColumnLike, ehh, it's a little complex, leave it).... So we can have some simple column class like IntegerColumn, StringColumn, DateColumn.....


By the way, I think a code generator maven plugin is needed.  I usually manually create a DB class which has static members of all the Tables and Columns, then I can use them without string literals to represent table or column which has a using expirence like jooq or empire-db. I believe a maven code generation plugin will do better. It can also create pojo class from database schema using underline naming method to camel naming method... So when we get a Dataset dataSet object, we can just like dataSet.extract(List<Person>.class) to get the data.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)