ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Youssef Khaye <y.kh...@unionsmarket.com>
Subject Re: connection to external database: part 2
Date Fri, 12 Dec 2014 16:46:56 GMT
I will try to answer, even if i don't understand your use case at 100%

Hi for your second question the answer is no.

For your first question you should show us your entityengine.xml
There is two different cases where  you can use a second database.


Case 1 use a diffrent delegator (from your first post, i think that you 
fill in this case), to get record you should instanciate

a  delegator using the name you declared in entityegine.xml
<delegator name="default" entity-model-reader="main" 
entity-group-reader="main" entity-eca-reader="main" 
distributed-cache-clear-enabled="false">
         <group-map group-name="org.ofbiz" datasource-name="localpostgres"/>
         <group-map group-name="org.ofbiz.olap" 
datasource-name="localpostgres"/>
         <group-map group-name="org.ofbiz.tenant" 
datasource-name="localpostgres"/>
</delegator>

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

then in your service
delegator = delagtor.geInstance("mysqlDb")
then use the entity API to get record from your DB.


Case 2
In the same delegator you may assign a diffrent dataSource, that point 
to the external DB, to a given package.

<delegator name="default" entity-model-reader="main" 
entity-group-reader="main" entity-eca-reader="main" 
distributed-cache-clear-enabled="false">
         <group-map group-name="org.ofbiz" datasource-name="localpostgres"/>
         <group-map group-name="com.custom 
datasource-name="sqlDataSource"/>
         <group-map group-name="org.ofbiz.olap" 
datasource-name="localpostgres"/>
         <group-map group-name="org.ofbiz.tenant" 
datasource-name="localpostgres"/>
</delegator>
In this case the defeault delegator you get in a service can fetch 
record from any entity in the com.custom package.

Personnaly, I use the first one if I need the external database in 
limited area of my OFBiz.

The second one is suitable if you need to access your external db in 
many areas of your OFBiz


Le 12/12/2014 09:03, info@agentur-m3.de a écrit :
> Hi All!
>
> after setting up the connection with an external database
> without errors I have two more questions, on which I
> could not find some specific information:
>
> (1) after setting up an entity, a delegator and
> I datasource, which seem to work together now,
> how (or where?) is the exchange of RECORDS with the
> external database? ofbiz does not seem to
> automatically detect and show the records from the
> mysql-database.
> Maybe my entity definitions are still wrong,
> but then without error messages.
> However: no records are imported or displayed
> in the view. So: how can I get them from the mysql-database?
>
> Also unexpected to me: when I create new records in ofbiz,
> they are displayed in ofbiz after creation (as one would
> expect for any regular entity) but they are not transferred to
> to the external mysql-database (which I guess could be
> the purpose of a entity with associated externally
> referenced datasource).
>
> So it seems that ofbiz did recognize the structure of
> the external mysql-database, but then ignores to
> exchange the data between ofbiz and the database.
>
> So how does ofbiz exchange records between
> ofbiz and the external database (in a synchronized way)?
>
> Is there further setup or custom implmentation necessary?
>
> (2) the setup of a datasource is placed in entityengine.xml
> in the framework/entity/config folder.
> Is there a way to extend it with entries
> defined in hot-deploy/.../entitydef/config/entityengine.xml ?
>
> I tried to setup another entityengine.xml there,
> but this approach seemed to be ignored by ofbiz.
>
>
> Thank you!
>
>
>
>
>
>
>
>
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message