Configuring db-data-config to import several entities

49 views
Skip to first unread message

pjmorce

unread,
Apr 26, 2012, 3:52:11 AM4/26/12
to sql-to-nosql-importer-discuss
Hello,

I am trying SQLToNoSQLImporter. I tried to import a table which is
related with another table.

To simplify, imagine my both tables are like this:

table1: [ ID, NAME, ID_Table2, DESCRIPTION]
table2: [ID, VALUE, DATE]

So I configured db-data-config to import table1 with the data of
table2:

<dataConfig>
<dataSource driver="org.postgresql.Driver" url="jdbc:postgresql://
eagan2:5432/DBTEST" user="user" password="pwd" batch-size="-1"/>
<document name="table1">
<entity name="table1" pk="ID" query="select * from table1 where
ID=1">
<field column="ID" name="ID" type="long"/>
<field column="NAME" name="NAME" type="string"/>
<field column="DESCRIPTION" name="DESCRIPTION" type="string"/>
<entity name="table2" pk="ID" query="select * from table2 where
ID='${table1.ID_Table2}'">
<field column="ID" name="ID" type="long"/>
<field column="VALUE" name="VALUE" type="integer"/>
<field column="DATE" name="DATE" type="date"/>
</entity>
</entity>
</document>
</dataConfig>

Using this configuration file, I should have a document created one my
database with the information of table1 on inside the same document,
the related information of table2, more or less like this:

{
_id: {
NAME
DESCRIPTION
table2 {
_id: {
VALUE
DATE
}
}
}
}

However, I would like to know if it is possible having other kind of
result, using only one configuration file: I would like to have, in
the same scenario, 2 documents created:
- one document with the data of table1
- one another document with the related data of table2
=> where both document would be linked by the table2 ID

I would like to have this kind of result:

{
id_table1: {
NAME
DESCRIPTION
ID_table2
}
}
ID_table2: {
VALUE
DATE
}
}
}

Is it possible to do that using SQLToNoSQLImporter? How?

Thank you

Best regards

sathis kumar

unread,
Apr 26, 2012, 5:43:34 AM4/26/12
to sql-to-nosql-i...@googlegroups.com
Nope.It can insert only one document at a time.If you want to import to two tables, just import twice with respective table configurations (i.e first time to Table1 then Table2).
--
Regards
 sathis


Reply all
Reply to author
Forward
0 new messages