[OFBiz] Users - problem integrating databases - config for two delegators for unique entity

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

[OFBiz] Users - problem integrating databases - config for two delegators for unique entity

Helmut Eggebert
Hi Users,

I am stuck on this and facing a very important deadline.  Responses highly
appreciated.

My problem relates to a post from 2003 on the dev list titled "'Same entity
name for a same delegator? is that possible?" but its more of a user issue.  
Here's the the post:
at http://lists.ofbiz.org/pipermail/dev/2003-November/003758.html

I am trying to integrate another application with OFBiz, and one of the
biggest issues we need to deal with is synchronizing the underlying
databases with each other. What this means is, a user that is created in
OFBiz must also have a corresponding user created in the other application,
and vice versa.

Our initial approach was to extend the Java services such as "createPerson"
to modify the other application database at the same time. However, the two
different tactics we tried seemed to run into a lot of problems, which I
will describe below.

1. Trying to access EJBs directly from the Java service, and letting the
EJBs perform the database changes. It seems that we will need to first
figure out how to integrate a EJB-capable web container, such as JBoss, with
OFBiz before this will work. This proved to be too complex and time
consuming and we chose to try the second approach.

2. Using the entity engine to make the database changes by accessing our
application database directly. Unfortunately for us, several of the other
application's tables have the same names as the OFBiz tables, such as
product, party and person. Since OFBiz does not support having a single
delegator access two different databases with tables that have the same
name, this is a problem.

After searching for a while on the web, I found the post regarding using two
delegators as a solution to the unique entity issue. However, after playing
around with configuration files, I keep running into errors such as,
"org.ofbiz.entity.GenericEntityException: Helper name not found for entity
JobSandbox" and sometimes, several thousand warnings that say helper cannot
be found.

I made the following changes in an attempt to implement two delegators:
1) In PartyServices.java, in the createPerson function, added the following
lines of code which are supposed to perform the database update on our
application's database:

GenericDelegator newDel = GenericDelegator.getGenericDelegator("mydb");
newDel.makeValue("Party", newPartyMap);

2) Updated entityengine.xml by adding these lines:

<delegator name="mydb"
        entity-model-reader="main"
        entity-group-reader="main"
        entity-eca-reader="main"
        distributed-cache-clear-enabled="false">
<group-map group-name="com.mycompany" datasource-name="mydb"/>
</delegator>

<datasource name="mydb"
        helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
        schema-name="public"
        field-type-name="postgres"
        check-on-start="false"
        add-missing-on-start="false"
        use-fk-initially-deferred="false"
        join-style="ansi">

        <read-data reader-name="seed"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <inline-jdbc
                jdbc-driver="org.postgresql.Driver"
                jdbc-uri="jdbc:postgresql://127.0.0.1/mydb"
                jdbc-username="user"
                jdbc-password="password"
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="20"/>
</datasource>

3) Updated the party application's configuration files:
entitygroup.xml --
        <entity-group group="com.mycompany" entity="Party" />
entitymodel.xml --
    <entity entity-name="Party"
    package-name="com.mycompany"
        title="Party Entity">
    <field name="partyId" type="numeric"></field>
    <field name="partyType" type="long-varchar"></field>
                <field name="partyDescription" type="long-varchar"></field>
                <field name="isMainParty" type="indicator"></field>
                ...
    </entity>

Note: I get a warning that "Party" is defined twice. Not sure how to get
around that, since I have two "Party" tables, one for OFBiz and one for the
other application, and they have different fields so I cannot just pick the
bigger one.

I would appreciate any feedback on what I'm doing wrong, as well as any
advice on which of the two approaches I mentioned above would be the better
option.

Thank you for your time.  I'm really in a bind.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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

Re: [OFBiz] Users - problem integrating databases - config for two delegators for unique entity

David E. Jones

Helmut,

It doesn't look like your multiple delegators are setup correctly. If  
you want a different set of entities for each delegator, they should  
each refer to a different model reader name. There are probably other  
issues there too, but no sense getting into that when....

You can have 2 different entities that refer to the same table name  
as long as the entity name is different... Just use the normal  
delegation pattern to access multiple databases (as described in the  
Entity Engine Guide and EE Configuration Guide, and which it sounds  
like you are okay with) and give your foreign entity a different name  
but override the default table name using the "table-name" attribute  
on the entity element (as described in the Entity Engine Guide). Then  
you won't have the entity name conflict and such.

-David


On Aug 12, 2005, at 6:45 PM, Helmut Eggebert wrote:

> Hi Users,
>
> I am stuck on this and facing a very important deadline.  Responses  
> highly appreciated.
>
> My problem relates to a post from 2003 on the dev list titled  
> "'Same entity name for a same delegator? is that possible?" but its  
> more of a user issue.  Here's the the post:
> at http://lists.ofbiz.org/pipermail/dev/2003-November/003758.html
>
> I am trying to integrate another application with OFBiz, and one of  
> the biggest issues we need to deal with is synchronizing the  
> underlying databases with each other. What this means is, a user  
> that is created in OFBiz must also have a corresponding user  
> created in the other application, and vice versa.
>
> Our initial approach was to extend the Java services such as  
> "createPerson" to modify the other application database at the same  
> time. However, the two different tactics we tried seemed to run  
> into a lot of problems, which I will describe below.
>
> 1. Trying to access EJBs directly from the Java service, and  
> letting the EJBs perform the database changes. It seems that we  
> will need to first figure out how to integrate a EJB-capable web  
> container, such as JBoss, with OFBiz before this will work. This  
> proved to be too complex and time consuming and we chose to try the  
> second approach.
>
> 2. Using the entity engine to make the database changes by  
> accessing our application database directly. Unfortunately for us,  
> several of the other application's tables have the same names as  
> the OFBiz tables, such as product, party and person. Since OFBiz  
> does not support having a single delegator access two different  
> databases with tables that have the same name, this is a problem.
>
> After searching for a while on the web, I found the post regarding  
> using two delegators as a solution to the unique entity issue.  
> However, after playing around with configuration files, I keep  
> running into errors such as,
> "org.ofbiz.entity.GenericEntityException: Helper name not found for  
> entity JobSandbox" and sometimes, several thousand warnings that  
> say helper cannot be found.
>
> I made the following changes in an attempt to implement two  
> delegators:
> 1) In PartyServices.java, in the createPerson function, added the  
> following lines of code which are supposed to perform the database  
> update on our application's database:
>
> GenericDelegator newDel = GenericDelegator.getGenericDelegator
> ("mydb");
> newDel.makeValue("Party", newPartyMap);
>
> 2) Updated entityengine.xml by adding these lines:
>
> <delegator name="mydb"
>     entity-model-reader="main"
>     entity-group-reader="main"
>     entity-eca-reader="main"
>     distributed-cache-clear-enabled="false">
> <group-map group-name="com.mycompany" datasource-name="mydb"/>
> </delegator>
>
> <datasource name="mydb"
>     helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
>     schema-name="public"
>     field-type-name="postgres"
>     check-on-start="false"
>     add-missing-on-start="false"
>     use-fk-initially-deferred="false"
>     join-style="ansi">
>
>     <read-data reader-name="seed"/>
>     <read-data reader-name="demo"/>
>     <read-data reader-name="ext"/>
>     <inline-jdbc
>         jdbc-driver="org.postgresql.Driver"
>         jdbc-uri="jdbc:postgresql://127.0.0.1/mydb"
>         jdbc-username="user"
>         jdbc-password="password"
>         isolation-level="ReadCommitted"
>         pool-minsize="2"
>         pool-maxsize="20"/>
> </datasource>
>
> 3) Updated the party application's configuration files:
> entitygroup.xml --
>     <entity-group group="com.mycompany" entity="Party" />
> entitymodel.xml --
>        <entity entity-name="Party"
>            package-name="com.mycompany"
>            title="Party Entity">
>            <field name="partyId" type="numeric"></field>
>            <field name="partyType" type="long-varchar"></field>
>         <field name="partyDescription" type="long-varchar"></field>
>         <field name="isMainParty" type="indicator"></field>
>         ...
>        </entity>
>
> Note: I get a warning that "Party" is defined twice. Not sure how  
> to get around that, since I have two "Party" tables, one for OFBiz  
> and one for the other application, and they have different fields  
> so I cannot just pick the bigger one.
>
> I would appreciate any feedback on what I'm doing wrong, as well as  
> any advice on which of the two approaches I mentioned above would  
> be the better option.
>
> Thank you for your time.  I'm really in a bind.
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today -  
> it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/ 
> direct/01/
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
>

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