[OFBiz] Dev - persisting dynamic entity created with ModelEntity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
Hi.

If I create a dynamic entity using the ModelEntity constructor, how do I
persist it in the database?  Or, are they automatically persisted?

Thanks,

Si
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
Meaning: do I need to do something to get the delegator to create the
table after creating the ModelEntity, or does a .create() or
.makeValue() cause it first to check the database and, if the table is
not there, create it based on the ModelEntity as well?

Si Chen wrote:

> Hi.
>
> If I create a dynamic entity using the ModelEntity constructor, how do
> I persist it in the database?  Or, are they automatically persisted?
>
> Thanks,
>
> Si
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

David E. Jones

No, it doesn't do anything like that, would be quite the performance  
overhead...

You can use the methods in the DatabaseUtil class to do this, that is  
where the chech/update database stuff is, and all the db maintenance  
routines.

-David


On Aug 8, 2005, at 9:03 PM, Si Chen wrote:



> Meaning: do I need to do something to get the delegator to create  
> the table after creating the ModelEntity, or does a .create()  
> or .makeValue() cause it first to check the database and, if the  
> table is not there, create it based on the ModelEntity as well?
>
> Si Chen wrote:
>
>
>
>
>> Hi.
>>
>> If I create a dynamic entity using the ModelEntity constructor,  
>> how do I persist it in the database?  Or, are they automatically  
>> persisted?
>>
>> Thanks,
>>
>> Si
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
>>
>>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
>
>



 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
That does make sense.

Is DatabaseUtil.createTable the best method to use?

I saw it had a Map of modelEntities.  Is this a Map of relation-type and
related model entities?

Si

David E. Jones wrote:

>
> No, it doesn't do anything like that, would be quite the performance  
> overhead...
>
> You can use the methods in the DatabaseUtil class to do this, that is  
> where the chech/update database stuff is, and all the db maintenance  
> routines.
>
> -David
>
>
> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>
>
>
>> Meaning: do I need to do something to get the delegator to create  
>> the table after creating the ModelEntity, or does a .create()  or
>> .makeValue() cause it first to check the database and, if the  table
>> is not there, create it based on the ModelEntity as well?
>>
>> Si Chen wrote:
>>
>>
>>
>>
>>> Hi.
>>>
>>> If I create a dynamic entity using the ModelEntity constructor,  how
>>> do I persist it in the database?  Or, are they automatically  
>>> persisted?
>>>
>>> Thanks,
>>>
>>> Si
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>>>
>>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
>>
>
>
>
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

David E. Jones

If I remember right the Map is a Map of all ModelEntity objects for  
all entities, for cases where things refer to other things, like  
foreign keys and such.

There is a main method that does the check/update of the database and  
it gets all of this stuff ready, and is called by the delegator on  
init if setup that way, it's also called in the check/update db JSP  
in webtools, which would be another good place to look for an example.

-David


On Aug 9, 2005, at 1:59 PM, Si Chen wrote:

> That does make sense.
>
> Is DatabaseUtil.createTable the best method to use?
>
> I saw it had a Map of modelEntities.  Is this a Map of relation-
> type and related model entities?
>
> Si
>
> David E. Jones wrote:
>
>
>>
>> No, it doesn't do anything like that, would be quite the  
>> performance  overhead...
>>
>> You can use the methods in the DatabaseUtil class to do this, that  
>> is  where the chech/update database stuff is, and all the db  
>> maintenance  routines.
>>
>> -David
>>
>>
>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>
>>
>>
>>
>>> Meaning: do I need to do something to get the delegator to  
>>> create  the table after creating the ModelEntity, or does  
>>> a .create()  or .makeValue() cause it first to check the database  
>>> and, if the  table is not there, create it based on the  
>>> ModelEntity as well?
>>>
>>> Si Chen wrote:
>>>
>>>
>>>
>>>
>>>
>>>> Hi.
>>>>
>>>> If I create a dynamic entity using the ModelEntity constructor,  
>>>> how do I persist it in the database?  Or, are they  
>>>> automatically  persisted?
>>>>
>>>> Thanks,
>>>>
>>>> Si
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
David,

Thanks for all your help so far.  I'm able to create the model entity
but delegator.makeValue(...) does not recognize it.

To create it I have done:
transposedSurvey = new ModelEntity();
transposedSurvey.setEntityName(entityName);
transposedSurvey.addField(new ModelField("surveyResponseId", "id-ne",
"surveyResponseId", true));
etc. etc.

And then I am able to use .getAllFieldNames() to list all the fields of
my model entity.  Then I did this, similar to the checkdb.jsp to, to
update my db:
fieldsToRepair = new ArrayList();
messages = new LinkedList();
helperName = delegator.getGroupHelperName(groupName);
dbUtil = new DatabaseUtil(helperName);
modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true, true, true);

But now, trying to use delegator.makeValue(...), I get an "Entity ....
is not a valid entity" or similar error, indicating that the delegator
does not recognize the model entity I've created.

   
transposedResponses.add(delegator.makeValue(transposedSurvey.getEntityName(),
responseValues));

Have I missed a step in actually registering the model entity with the
delegator, or did the DatabaseUtil.checkDb do that?  Or, is it possibly
to create a GenericValue directly from a ModelEntity without adding it
to the database?

Thanks....

Si

PS This is a fun project I'm playing with.  The idea is to transpose the
normalized rows of a survey's response answers into a column format,
with each column being a question of a survey and each row being all the
answers of a response.  I'll post it when I get it all to work...  :)

David E. Jones wrote:

>
> If I remember right the Map is a Map of all ModelEntity objects for  
> all entities, for cases where things refer to other things, like  
> foreign keys and such.
>
> There is a main method that does the check/update of the database and  
> it gets all of this stuff ready, and is called by the delegator on  
> init if setup that way, it's also called in the check/update db JSP  
> in webtools, which would be another good place to look for an example.
>
> -David
>
>
> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>
>> That does make sense.
>>
>> Is DatabaseUtil.createTable the best method to use?
>>
>> I saw it had a Map of modelEntities.  Is this a Map of relation- type
>> and related model entities?
>>
>> Si
>>
>> David E. Jones wrote:
>>
>>
>>>
>>> No, it doesn't do anything like that, would be quite the  
>>> performance  overhead...
>>>
>>> You can use the methods in the DatabaseUtil class to do this, that  
>>> is  where the chech/update database stuff is, and all the db  
>>> maintenance  routines.
>>>
>>> -David
>>>
>>>
>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>
>>>
>>>
>>>
>>>> Meaning: do I need to do something to get the delegator to  create  
>>>> the table after creating the ModelEntity, or does  a .create()  or
>>>> .makeValue() cause it first to check the database  and, if the  
>>>> table is not there, create it based on the  ModelEntity as well?
>>>>
>>>> Si Chen wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hi.
>>>>>
>>>>> If I create a dynamic entity using the ModelEntity constructor,  
>>>>> how do I persist it in the database?  Or, are they  automatically  
>>>>> persisted?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Si
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Adam Heath-2
On Sun, 14 Aug 2005, Si Chen wrote:

> David,
>
> Thanks for all your help so far.  I'm able to create the model entity
> but delegator.makeValue(...) does not recognize it.
>
> To create it I have done:
> transposedSurvey = new ModelEntity();
> transposedSurvey.setEntityName(entityName);
> transposedSurvey.addField(new ModelField("surveyResponseId", "id-ne",
> "surveyResponseId", true));
> etc. etc.
>
> And then I am able to use .getAllFieldNames() to list all the fields of
> my model entity.  Then I did this, similar to the checkdb.jsp to, to
> update my db:
> fieldsToRepair = new ArrayList();
> messages = new LinkedList();
> helperName = delegator.getGroupHelperName(groupName);
> dbUtil = new DatabaseUtil(helperName);
> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true, true, true);
>
> But now, trying to use delegator.makeValue(...), I get an "Entity ....
> is not a valid entity" or similar error, indicating that the delegator
> does not recognize the model entity I've created.
>
>
> transposedResponses.add(delegator.makeValue(transposedSurvey.getEntityName(),
> responseValues));
>
> Have I missed a step in actually registering the model entity with the
> delegator, or did the DatabaseUtil.checkDb do that?  Or, is it possibly
> to create a GenericValue directly from a ModelEntity without adding it
> to the database?

You need to add it to the delegator; the delegator maintains an internal list
of valid entities(per helper).
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
Do you know how to do that?  Is there a GenericDelegator method for
doing it?

Si

Adam Heath wrote:

>On Sun, 14 Aug 2005, Si Chen wrote:
>
>  
>
>>David,
>>
>>Thanks for all your help so far.  I'm able to create the model entity
>>but delegator.makeValue(...) does not recognize it.
>>
>>To create it I have done:
>>transposedSurvey = new ModelEntity();
>>transposedSurvey.setEntityName(entityName);
>>transposedSurvey.addField(new ModelField("surveyResponseId", "id-ne",
>>"surveyResponseId", true));
>>etc. etc.
>>
>>And then I am able to use .getAllFieldNames() to list all the fields of
>>my model entity.  Then I did this, similar to the checkdb.jsp to, to
>>update my db:
>>fieldsToRepair = new ArrayList();
>>messages = new LinkedList();
>>helperName = delegator.getGroupHelperName(groupName);
>>dbUtil = new DatabaseUtil(helperName);
>>modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
>>dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true, true, true);
>>
>>But now, trying to use delegator.makeValue(...), I get an "Entity ....
>>is not a valid entity" or similar error, indicating that the delegator
>>does not recognize the model entity I've created.
>>
>>
>>transposedResponses.add(delegator.makeValue(transposedSurvey.getEntityName(),
>>responseValues));
>>
>>Have I missed a step in actually registering the model entity with the
>>delegator, or did the DatabaseUtil.checkDb do that?  Or, is it possibly
>>to create a GenericValue directly from a ModelEntity without adding it
>>to the database?
>>    
>>
>
>You need to add it to the delegator; the delegator maintains an internal list
>of valid entities(per helper).
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
>  
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Adam Heath-2
On Sun, 14 Aug 2005, Si Chen wrote:

> Do you know how to do that?  Is there a GenericDelegator method for
> doing it?

I see no direct way to do this.

You'd have to get the ModelReader, then add the ModelEntity you've just
created to the entityCache.  However, there is no way to this outside of the
constructors.
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

David E. Jones
In reply to this post by Si Chen-2

Si,

This is getting pretty deep into the Entity Engine code. There are  
some entity editing JSPs in WebTools (with no links to them anymore,  
we aren't keeping them up to date) but there is some code there that  
creates and registers new entity definitions.

Still, this seems a little bit extreme no matter what you are trying  
to do, and I'm still not sure what that is or how this might fit  
in... Perhaps there is a better way?

-David


On Aug 14, 2005, at 2:20 PM, Si Chen wrote:

> David,
>
> Thanks for all your help so far.  I'm able to create the model  
> entity but delegator.makeValue(...) does not recognize it.
>
> To create it I have done:
> transposedSurvey = new ModelEntity();
> transposedSurvey.setEntityName(entityName);
> transposedSurvey.addField(new ModelField("surveyResponseId", "id-
> ne", "surveyResponseId", true));
> etc. etc.
>
> And then I am able to use .getAllFieldNames() to list all the  
> fields of my model entity.  Then I did this, similar to the  
> checkdb.jsp to, to update my db:
> fieldsToRepair = new ArrayList();
> messages = new LinkedList();
> helperName = delegator.getGroupHelperName(groupName);
> dbUtil = new DatabaseUtil(helperName);
> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true, true,  
> true);
>
> But now, trying to use delegator.makeValue(...), I get an  
> "Entity .... is not a valid entity" or similar error, indicating  
> that the delegator does not recognize the model entity I've created.
>
>    transposedResponses.add(delegator.makeValue
> (transposedSurvey.getEntityName(), responseValues));
>
> Have I missed a step in actually registering the model entity with  
> the delegator, or did the DatabaseUtil.checkDb do that?  Or, is it  
> possibly to create a GenericValue directly from a ModelEntity  
> without adding it to the database?
> Thanks....
>
> Si
>
> PS This is a fun project I'm playing with.  The idea is to  
> transpose the normalized rows of a survey's response answers into a  
> column format, with each column being a question of a survey and  
> each row being all the answers of a response.  I'll post it when I  
> get it all to work...  :)
>
> David E. Jones wrote:
>
>
>>
>> If I remember right the Map is a Map of all ModelEntity objects  
>> for  all entities, for cases where things refer to other things,  
>> like  foreign keys and such.
>>
>> There is a main method that does the check/update of the database  
>> and  it gets all of this stuff ready, and is called by the  
>> delegator on  init if setup that way, it's also called in the  
>> check/update db JSP  in webtools, which would be another good  
>> place to look for an example.
>>
>> -David
>>
>>
>> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>>
>>
>>> That does make sense.
>>>
>>> Is DatabaseUtil.createTable the best method to use?
>>>
>>> I saw it had a Map of modelEntities.  Is this a Map of relation-  
>>> type and related model entities?
>>>
>>> Si
>>>
>>> David E. Jones wrote:
>>>
>>>
>>>
>>>>
>>>> No, it doesn't do anything like that, would be quite the  
>>>> performance  overhead...
>>>>
>>>> You can use the methods in the DatabaseUtil class to do this,  
>>>> that  is  where the chech/update database stuff is, and all the  
>>>> db  maintenance  routines.
>>>>
>>>> -David
>>>>
>>>>
>>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Meaning: do I need to do something to get the delegator to  
>>>>> create  the table after creating the ModelEntity, or does  
>>>>> a .create()  or .makeValue() cause it first to check the  
>>>>> database  and, if the  table is not there, create it based on  
>>>>> the  ModelEntity as well?
>>>>>
>>>>> Si Chen wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi.
>>>>>>
>>>>>> If I create a dynamic entity using the ModelEntity  
>>>>>> constructor,   how do I persist it in the database?  Or, are  
>>>>>> they  automatically  persisted?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Si
>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> [hidden email]
>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
Well, yes, there are easier ways to do it, I'm sure.  I was just hoping
to learn something new along the way, ie how to create and persist new
entities in the code.  I guess it's not within the normal sphere of what
the entity engine is to be used for?

Si

David E. Jones wrote:

>
> Si,
>
> This is getting pretty deep into the Entity Engine code. There are  
> some entity editing JSPs in WebTools (with no links to them anymore,  
> we aren't keeping them up to date) but there is some code there that  
> creates and registers new entity definitions.
>
> Still, this seems a little bit extreme no matter what you are trying  
> to do, and I'm still not sure what that is or how this might fit  
> in... Perhaps there is a better way?
>
> -David
>
>
> On Aug 14, 2005, at 2:20 PM, Si Chen wrote:
>
>> David,
>>
>> Thanks for all your help so far.  I'm able to create the model  
>> entity but delegator.makeValue(...) does not recognize it.
>>
>> To create it I have done:
>> transposedSurvey = new ModelEntity();
>> transposedSurvey.setEntityName(entityName);
>> transposedSurvey.addField(new ModelField("surveyResponseId", "id-
>> ne", "surveyResponseId", true));
>> etc. etc.
>>
>> And then I am able to use .getAllFieldNames() to list all the  fields
>> of my model entity.  Then I did this, similar to the  checkdb.jsp to,
>> to update my db:
>> fieldsToRepair = new ArrayList();
>> messages = new LinkedList();
>> helperName = delegator.getGroupHelperName(groupName);
>> dbUtil = new DatabaseUtil(helperName);
>> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
>> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true, true,  
>> true);
>>
>> But now, trying to use delegator.makeValue(...), I get an  "Entity
>> .... is not a valid entity" or similar error, indicating  that the
>> delegator does not recognize the model entity I've created.
>>
>>    transposedResponses.add(delegator.makeValue
>> (transposedSurvey.getEntityName(), responseValues));
>>
>> Have I missed a step in actually registering the model entity with  
>> the delegator, or did the DatabaseUtil.checkDb do that?  Or, is it  
>> possibly to create a GenericValue directly from a ModelEntity  
>> without adding it to the database?
>> Thanks....
>>
>> Si
>>
>> PS This is a fun project I'm playing with.  The idea is to  transpose
>> the normalized rows of a survey's response answers into a  column
>> format, with each column being a question of a survey and  each row
>> being all the answers of a response.  I'll post it when I  get it all
>> to work...  :)
>>
>> David E. Jones wrote:
>>
>>
>>>
>>> If I remember right the Map is a Map of all ModelEntity objects  
>>> for  all entities, for cases where things refer to other things,  
>>> like  foreign keys and such.
>>>
>>> There is a main method that does the check/update of the database  
>>> and  it gets all of this stuff ready, and is called by the  
>>> delegator on  init if setup that way, it's also called in the  
>>> check/update db JSP  in webtools, which would be another good  place
>>> to look for an example.
>>>
>>> -David
>>>
>>>
>>> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>>>
>>>
>>>> That does make sense.
>>>>
>>>> Is DatabaseUtil.createTable the best method to use?
>>>>
>>>> I saw it had a Map of modelEntities.  Is this a Map of relation-  
>>>> type and related model entities?
>>>>
>>>> Si
>>>>
>>>> David E. Jones wrote:
>>>>
>>>>
>>>>
>>>>>
>>>>> No, it doesn't do anything like that, would be quite the  
>>>>> performance  overhead...
>>>>>
>>>>> You can use the methods in the DatabaseUtil class to do this,  
>>>>> that  is  where the chech/update database stuff is, and all the  
>>>>> db  maintenance  routines.
>>>>>
>>>>> -David
>>>>>
>>>>>
>>>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Meaning: do I need to do something to get the delegator to  
>>>>>> create  the table after creating the ModelEntity, or does   a
>>>>>> .create()  or .makeValue() cause it first to check the  database  
>>>>>> and, if the  table is not there, create it based on  the  
>>>>>> ModelEntity as well?
>>>>>>
>>>>>> Si Chen wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi.
>>>>>>>
>>>>>>> If I create a dynamic entity using the ModelEntity  
>>>>>>> constructor,   how do I persist it in the database?  Or, are  
>>>>>>> they  automatically  persisted?
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Si
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> [hidden email]
>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> [hidden email]
>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>
>------------------------------------------------------------------------
>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

David E. Jones

No, it's not really meant to be used this way. Entities are usually  
designed in advance rather than created on the fly. Database tables  
are usually used this way too, though it is certainly possible to  
create temporary tables and such and internally databases do this all  
the time, it's just not something we have really wanted to do much in  
our applications.

Still, I imagine it's interesting (and maybe even fun?) to play  
with... We could certainly create some additions to the Entity Engine  
to make this easier, as right now it's really meant to by done as an  
internal operation.

-David


On Aug 15, 2005, at 11:02 AM, Si Chen wrote:

> Well, yes, there are easier ways to do it, I'm sure.  I was just  
> hoping to learn something new along the way, ie how to create and  
> persist new entities in the code.  I guess it's not within the  
> normal sphere of what the entity engine is to be used for?
>
> Si
>
> David E. Jones wrote:
>
>
>>
>> Si,
>>
>> This is getting pretty deep into the Entity Engine code. There  
>> are  some entity editing JSPs in WebTools (with no links to them  
>> anymore,  we aren't keeping them up to date) but there is some  
>> code there that  creates and registers new entity definitions.
>>
>> Still, this seems a little bit extreme no matter what you are  
>> trying  to do, and I'm still not sure what that is or how this  
>> might fit  in... Perhaps there is a better way?
>>
>> -David
>>
>>
>> On Aug 14, 2005, at 2:20 PM, Si Chen wrote:
>>
>>
>>> David,
>>>
>>> Thanks for all your help so far.  I'm able to create the model  
>>> entity but delegator.makeValue(...) does not recognize it.
>>>
>>> To create it I have done:
>>> transposedSurvey = new ModelEntity();
>>> transposedSurvey.setEntityName(entityName);
>>> transposedSurvey.addField(new ModelField("surveyResponseId", "id-  
>>> ne", "surveyResponseId", true));
>>> etc. etc.
>>>
>>> And then I am able to use .getAllFieldNames() to list all the  
>>> fields of my model entity.  Then I did this, similar to the  
>>> checkdb.jsp to, to update my db:
>>> fieldsToRepair = new ArrayList();
>>> messages = new LinkedList();
>>> helperName = delegator.getGroupHelperName(groupName);
>>> dbUtil = new DatabaseUtil(helperName);
>>> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
>>> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true,  
>>> true,  true);
>>>
>>> But now, trying to use delegator.makeValue(...), I get an  
>>> "Entity .... is not a valid entity" or similar error, indicating  
>>> that the delegator does not recognize the model entity I've created.
>>>
>>>    transposedResponses.add(delegator.makeValue  
>>> (transposedSurvey.getEntityName(), responseValues));
>>>
>>> Have I missed a step in actually registering the model entity  
>>> with  the delegator, or did the DatabaseUtil.checkDb do that?  
>>> Or, is it  possibly to create a GenericValue directly from a  
>>> ModelEntity  without adding it to the database?
>>> Thanks....
>>>
>>> Si
>>>
>>> PS This is a fun project I'm playing with.  The idea is to  
>>> transpose the normalized rows of a survey's response answers into  
>>> a  column format, with each column being a question of a survey  
>>> and  each row being all the answers of a response.  I'll post it  
>>> when I  get it all to work...  :)
>>>
>>> David E. Jones wrote:
>>>
>>>
>>>
>>>>
>>>> If I remember right the Map is a Map of all ModelEntity objects  
>>>> for  all entities, for cases where things refer to other  
>>>> things,  like  foreign keys and such.
>>>>
>>>> There is a main method that does the check/update of the  
>>>> database  and  it gets all of this stuff ready, and is called by  
>>>> the  delegator on  init if setup that way, it's also called in  
>>>> the  check/update db JSP  in webtools, which would be another  
>>>> good  place to look for an example.
>>>>
>>>> -David
>>>>
>>>>
>>>> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>>>>
>>>>
>>>>
>>>>> That does make sense.
>>>>>
>>>>> Is DatabaseUtil.createTable the best method to use?
>>>>>
>>>>> I saw it had a Map of modelEntities.  Is this a Map of  
>>>>> relation-  type and related model entities?
>>>>>
>>>>> Si
>>>>>
>>>>> David E. Jones wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> No, it doesn't do anything like that, would be quite the    
>>>>>> performance  overhead...
>>>>>>
>>>>>> You can use the methods in the DatabaseUtil class to do this,  
>>>>>> that  is  where the chech/update database stuff is, and all  
>>>>>> the  db  maintenance  routines.
>>>>>>
>>>>>> -David
>>>>>>
>>>>>>
>>>>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Meaning: do I need to do something to get the delegator to    
>>>>>>> create  the table after creating the ModelEntity, or does    
>>>>>>> a .create()  or .makeValue() cause it first to check the  
>>>>>>> database  and, if the  table is not there, create it based  
>>>>>>> on  the  ModelEntity as well?
>>>>>>>
>>>>>>> Si Chen wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi.
>>>>>>>>
>>>>>>>> If I create a dynamic entity using the ModelEntity  
>>>>>>>> constructor,   how do I persist it in the database?  Or,  
>>>>>>>> are  they  automatically  persisted?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Si
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> [hidden email]
>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> [hidden email]
>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> [hidden email]
>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> ---
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
It turns out I needed this line:
delegator.getModelGroupReader().getGroupCache().put(entityName, groupName);

which I found in EditEntity.jsp.  Now the dynamic entity is registered
with the delegator and I can work with it.  :-)

Thanks for the tip--

Si

David E. Jones wrote:

>
> No, it's not really meant to be used this way. Entities are usually  
> designed in advance rather than created on the fly. Database tables  
> are usually used this way too, though it is certainly possible to  
> create temporary tables and such and internally databases do this all  
> the time, it's just not something we have really wanted to do much in  
> our applications.
>
> Still, I imagine it's interesting (and maybe even fun?) to play  
> with... We could certainly create some additions to the Entity Engine  
> to make this easier, as right now it's really meant to by done as an  
> internal operation.
>
> -David
>
>
> On Aug 15, 2005, at 11:02 AM, Si Chen wrote:
>
>> Well, yes, there are easier ways to do it, I'm sure.  I was just  
>> hoping to learn something new along the way, ie how to create and  
>> persist new entities in the code.  I guess it's not within the  
>> normal sphere of what the entity engine is to be used for?
>>
>> Si
>>
>> David E. Jones wrote:
>>
>>
>>>
>>> Si,
>>>
>>> This is getting pretty deep into the Entity Engine code. There  are  
>>> some entity editing JSPs in WebTools (with no links to them  
>>> anymore,  we aren't keeping them up to date) but there is some  code
>>> there that  creates and registers new entity definitions.
>>>
>>> Still, this seems a little bit extreme no matter what you are  
>>> trying  to do, and I'm still not sure what that is or how this  
>>> might fit  in... Perhaps there is a better way?
>>>
>>> -David
>>>
>>>
>>> On Aug 14, 2005, at 2:20 PM, Si Chen wrote:
>>>
>>>
>>>> David,
>>>>
>>>> Thanks for all your help so far.  I'm able to create the model  
>>>> entity but delegator.makeValue(...) does not recognize it.
>>>>
>>>> To create it I have done:
>>>> transposedSurvey = new ModelEntity();
>>>> transposedSurvey.setEntityName(entityName);
>>>> transposedSurvey.addField(new ModelField("surveyResponseId", "id-  
>>>> ne", "surveyResponseId", true));
>>>> etc. etc.
>>>>
>>>> And then I am able to use .getAllFieldNames() to list all the  
>>>> fields of my model entity.  Then I did this, similar to the  
>>>> checkdb.jsp to, to update my db:
>>>> fieldsToRepair = new ArrayList();
>>>> messages = new LinkedList();
>>>> helperName = delegator.getGroupHelperName(groupName);
>>>> dbUtil = new DatabaseUtil(helperName);
>>>> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
>>>> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true,  
>>>> true,  true);
>>>>
>>>> But now, trying to use delegator.makeValue(...), I get an   "Entity
>>>> .... is not a valid entity" or similar error, indicating   that the
>>>> delegator does not recognize the model entity I've created.
>>>>
>>>>    transposedResponses.add(delegator.makeValue  
>>>> (transposedSurvey.getEntityName(), responseValues));
>>>>
>>>> Have I missed a step in actually registering the model entity  
>>>> with  the delegator, or did the DatabaseUtil.checkDb do that?   Or,
>>>> is it  possibly to create a GenericValue directly from a  
>>>> ModelEntity  without adding it to the database?
>>>> Thanks....
>>>>
>>>> Si
>>>>
>>>> PS This is a fun project I'm playing with.  The idea is to  
>>>> transpose the normalized rows of a survey's response answers into  
>>>> a  column format, with each column being a question of a survey  
>>>> and  each row being all the answers of a response.  I'll post it  
>>>> when I  get it all to work...  :)
>>>>
>>>> David E. Jones wrote:
>>>>
>>>>
>>>>
>>>>>
>>>>> If I remember right the Map is a Map of all ModelEntity objects  
>>>>> for  all entities, for cases where things refer to other  things,  
>>>>> like  foreign keys and such.
>>>>>
>>>>> There is a main method that does the check/update of the  
>>>>> database  and  it gets all of this stuff ready, and is called by  
>>>>> the  delegator on  init if setup that way, it's also called in  
>>>>> the  check/update db JSP  in webtools, which would be another  
>>>>> good  place to look for an example.
>>>>>
>>>>> -David
>>>>>
>>>>>
>>>>> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>>>>>
>>>>>
>>>>>
>>>>>> That does make sense.
>>>>>>
>>>>>> Is DatabaseUtil.createTable the best method to use?
>>>>>>
>>>>>> I saw it had a Map of modelEntities.  Is this a Map of  
>>>>>> relation-  type and related model entities?
>>>>>>
>>>>>> Si
>>>>>>
>>>>>> David E. Jones wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> No, it doesn't do anything like that, would be quite the    
>>>>>>> performance  overhead...
>>>>>>>
>>>>>>> You can use the methods in the DatabaseUtil class to do this,  
>>>>>>> that  is  where the chech/update database stuff is, and all  
>>>>>>> the  db  maintenance  routines.
>>>>>>>
>>>>>>> -David
>>>>>>>
>>>>>>>
>>>>>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Meaning: do I need to do something to get the delegator to    
>>>>>>>> create  the table after creating the ModelEntity, or does    a
>>>>>>>> .create()  or .makeValue() cause it first to check the  
>>>>>>>> database  and, if the  table is not there, create it based  on  
>>>>>>>> the  ModelEntity as well?
>>>>>>>>
>>>>>>>> Si Chen wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hi.
>>>>>>>>>
>>>>>>>>> If I create a dynamic entity using the ModelEntity  
>>>>>>>>> constructor,   how do I persist it in the database?  Or,  are  
>>>>>>>>> they  automatically  persisted?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Si
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Dev mailing list
>>>>>>>>> [hidden email]
>>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> [hidden email]
>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> [hidden email]
>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> [hidden email]
>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> ---
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>
>------------------------------------------------------------------------
>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - persisting dynamic entity created with ModelEntity

Si Chen-2
Sorry - last email was wrong.  This is actually the entire sequence:

// 1. create a model entity
transposedSurvey = new ModelEntity();
transposedSurvey.setEntityName(entityName);
transposedSurvey.setTableName(ModelUtil.javaNameToDbName(entityName));
// 2. register it with the delegator
reader = delegator.getModelReader();
reader.getEntityCache().put(entityName, transposedSurvey);
// 3. register its group reader
delegator.getModelGroupReader().getGroupCache().put(entityName, groupName);
// 4. now add fields
transposedSurvey.addField(new ModelField("surveyResponseId", "id-ne",
"surveyResponseId", true));



Si Chen wrote:

> It turns out I needed this line:
> delegator.getModelGroupReader().getGroupCache().put(entityName,
> groupName);
>
> which I found in EditEntity.jsp.  Now the dynamic entity is registered
> with the delegator and I can work with it.  :-)
>
> Thanks for the tip--
>
> Si
>
> David E. Jones wrote:
>
>>
>> No, it's not really meant to be used this way. Entities are usually  
>> designed in advance rather than created on the fly. Database tables  
>> are usually used this way too, though it is certainly possible to  
>> create temporary tables and such and internally databases do this
>> all  the time, it's just not something we have really wanted to do
>> much in  our applications.
>>
>> Still, I imagine it's interesting (and maybe even fun?) to play  
>> with... We could certainly create some additions to the Entity
>> Engine  to make this easier, as right now it's really meant to by
>> done as an  internal operation.
>>
>> -David
>>
>>
>> On Aug 15, 2005, at 11:02 AM, Si Chen wrote:
>>
>>> Well, yes, there are easier ways to do it, I'm sure.  I was just  
>>> hoping to learn something new along the way, ie how to create and  
>>> persist new entities in the code.  I guess it's not within the  
>>> normal sphere of what the entity engine is to be used for?
>>>
>>> Si
>>>
>>> David E. Jones wrote:
>>>
>>>
>>>>
>>>> Si,
>>>>
>>>> This is getting pretty deep into the Entity Engine code. There  
>>>> are  some entity editing JSPs in WebTools (with no links to them  
>>>> anymore,  we aren't keeping them up to date) but there is some  
>>>> code there that  creates and registers new entity definitions.
>>>>
>>>> Still, this seems a little bit extreme no matter what you are  
>>>> trying  to do, and I'm still not sure what that is or how this  
>>>> might fit  in... Perhaps there is a better way?
>>>>
>>>> -David
>>>>
>>>>
>>>> On Aug 14, 2005, at 2:20 PM, Si Chen wrote:
>>>>
>>>>
>>>>> David,
>>>>>
>>>>> Thanks for all your help so far.  I'm able to create the model  
>>>>> entity but delegator.makeValue(...) does not recognize it.
>>>>>
>>>>> To create it I have done:
>>>>> transposedSurvey = new ModelEntity();
>>>>> transposedSurvey.setEntityName(entityName);
>>>>> transposedSurvey.addField(new ModelField("surveyResponseId", "id-  
>>>>> ne", "surveyResponseId", true));
>>>>> etc. etc.
>>>>>
>>>>> And then I am able to use .getAllFieldNames() to list all the  
>>>>> fields of my model entity.  Then I did this, similar to the  
>>>>> checkdb.jsp to, to update my db:
>>>>> fieldsToRepair = new ArrayList();
>>>>> messages = new LinkedList();
>>>>> helperName = delegator.getGroupHelperName(groupName);
>>>>> dbUtil = new DatabaseUtil(helperName);
>>>>> modelEntities = UtilMisc.toMap(entityName, transposedSurvey);
>>>>> dbUtil.checkDb(modelEntities, fieldsToRepair, messages, true,  
>>>>> true,  true);
>>>>>
>>>>> But now, trying to use delegator.makeValue(...), I get an  
>>>>> "Entity .... is not a valid entity" or similar error, indicating  
>>>>> that the delegator does not recognize the model entity I've created.
>>>>>
>>>>>    transposedResponses.add(delegator.makeValue  
>>>>> (transposedSurvey.getEntityName(), responseValues));
>>>>>
>>>>> Have I missed a step in actually registering the model entity  
>>>>> with  the delegator, or did the DatabaseUtil.checkDb do that?  
>>>>> Or, is it  possibly to create a GenericValue directly from a  
>>>>> ModelEntity  without adding it to the database?
>>>>> Thanks....
>>>>>
>>>>> Si
>>>>>
>>>>> PS This is a fun project I'm playing with.  The idea is to  
>>>>> transpose the normalized rows of a survey's response answers into  
>>>>> a  column format, with each column being a question of a survey  
>>>>> and  each row being all the answers of a response.  I'll post it  
>>>>> when I  get it all to work...  :)
>>>>>
>>>>> David E. Jones wrote:
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> If I remember right the Map is a Map of all ModelEntity objects  
>>>>>> for  all entities, for cases where things refer to other  
>>>>>> things,  like  foreign keys and such.
>>>>>>
>>>>>> There is a main method that does the check/update of the  
>>>>>> database  and  it gets all of this stuff ready, and is called by  
>>>>>> the  delegator on  init if setup that way, it's also called in  
>>>>>> the  check/update db JSP  in webtools, which would be another  
>>>>>> good  place to look for an example.
>>>>>>
>>>>>> -David
>>>>>>
>>>>>>
>>>>>> On Aug 9, 2005, at 1:59 PM, Si Chen wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> That does make sense.
>>>>>>>
>>>>>>> Is DatabaseUtil.createTable the best method to use?
>>>>>>>
>>>>>>> I saw it had a Map of modelEntities.  Is this a Map of  
>>>>>>> relation-  type and related model entities?
>>>>>>>
>>>>>>> Si
>>>>>>>
>>>>>>> David E. Jones wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> No, it doesn't do anything like that, would be quite the    
>>>>>>>> performance  overhead...
>>>>>>>>
>>>>>>>> You can use the methods in the DatabaseUtil class to do this,  
>>>>>>>> that  is  where the chech/update database stuff is, and all  
>>>>>>>> the  db  maintenance  routines.
>>>>>>>>
>>>>>>>> -David
>>>>>>>>
>>>>>>>>
>>>>>>>> On Aug 8, 2005, at 9:03 PM, Si Chen wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Meaning: do I need to do something to get the delegator to    
>>>>>>>>> create  the table after creating the ModelEntity, or does    a
>>>>>>>>> .create()  or .makeValue() cause it first to check the  
>>>>>>>>> database  and, if the  table is not there, create it based  
>>>>>>>>> on  the  ModelEntity as well?
>>>>>>>>>
>>>>>>>>> Si Chen wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hi.
>>>>>>>>>>
>>>>>>>>>> If I create a dynamic entity using the ModelEntity  
>>>>>>>>>> constructor,   how do I persist it in the database?  Or,  
>>>>>>>>>> are  they  automatically  persisted?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>>
>>>>>>>>>> Si
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Dev mailing list
>>>>>>>>>> [hidden email]
>>>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Dev mailing list
>>>>>>>>> [hidden email]
>>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> [hidden email]
>>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> [hidden email]
>>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Dev mailing list
>>>>>> [hidden email]
>>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>>
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [hidden email]
>>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> ---
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [hidden email]
>>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>>
>>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev