Hi,

Cayenne can help with #3. Generic object functionality is there. As Tony said 
elsewhere in this thread, this is not the most common way of doing things, so 
there is a lack of high quality examples, but it can be done. There are a few 
possible flows. Here is one example:

1. Implement a custom DataMapLoader that dynamically reverse-engineers your DB 
schema using cayenne-datasync API [1]. You may need to borrow code from 
DefaultDbImportAction.java [2].
2. Start ServerRuntime instance with the custom DataMapLoader above (can be 
added via an extension Module):

Now that I think of it, #1 should probably be a part of Cayenne (so we'd gladly 
accept it as a contribution :)). 

> I want to use cayenne with linkREST to provide a rest data api. Hope there 
> are some advice~

Is that also in the dynamic scenario? Or are we talking a more "classic" 
approach, when you know the model upfront. 

FWIW I wanted to prototype a Cayenne / LinkRest extension for some time that 
starts without any ORM mapping, and when you point it to a previously unknown 
database, it reverse-engineers it and creates a bunch of LinkRest endpoints on 
the fly. Never got around to doing it, but I still like the idea.

Andrus

[1] 
https://github.com/apache/cayenne/tree/master/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbimport
[2] 
https://github.com/apache/cayenne/blob/master/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbimport/DefaultDbImportAction.java


> On Jul 22, 2018, at 6:40 PM, 刘波 <[email protected]> wrote:
> 
> hi Andrus,
> thanks very much!
> 
> I've watching your video on youtube that introduce the Cayenne framework one 
> hour ago this evening~
> 
> I know Apache Cayenne in yesterday, and find it a very exciting framework 
> maybe can fit our business  requirement.
> 
> We need dynamically create data table in java code at runtime, the user case 
> is:
> 1.user define a table in web form, such as table name, columns, columns type.
> 2.then, we need to create a table according the user definition in mysql 
> database.
> 3.user then can use CRUD action on that table, for example, 
> save,select,update,delete,pagination,etc...
> 
> I want to use cayenne with linkREST to provide a rest data api. Hope there 
> are some advice~
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------ 原始邮件 ------------------
> 发件人: "Andrus Adamchik"<[email protected]>;
> 发送时间: 2018年7月22日(星期天) 晚上11:15
> 收件人: "user"<[email protected]>;
> 抄送: "刘波"<[email protected]>;
> 主题: Re: is is possible to dynamically create entity in cayenne?
> 
> Hi there,
> 
> The short answer is that org.apache.cayenne.CayenneDataObject is that Java 
> object that every generic object can be mapped to. Will be happy to expand 
> this answer if you have any follow up questions.
> 
> (Also I noticed you are not subscribed to the list, so you may miss some 
> replies that are sent to the list only. Everything will be in the list 
> archives of course).
> 
> Andrus
> 
> 
> 
> > On Jul 22, 2018, at 3:37 PM, 刘波 <[email protected]> wrote:
> > 
> > Hi users,
> > 
> > 
> > I'm new to cayenne, we face a problem recently. 
> > 
> > 
> > we want to dynamically create the table in mysql, and it's corresponding 
> > entity.
> > 
> > 
> > we find the Generic Objects, but it seems need a specified java class 
> > before.
> > 
> > 
> > Any ideas, 
> > thanks~

Reply via email to