Reputation: 1548
I've a table Categories
which has Skins
and which has Images
Categories : id, Name
Skin : id, name
CategorySkins : CategoryID, SkinID
Images : id, name
SkinImages: Skinid, ImageID
my question is to save a single Category
instance with a few Skins
and those Skins
with a few Images
.
I've tried to build insert string dynamically, but I don't like this approach.
P.S. Is it possible to pass data like this: Catogory with list of skins and with list of images. as list to mysql procedure? Or simple is it possible to pass array as a parameter to procedure? Any suggestions about other way of solving this problem?
Upvotes: 1
Views: 429
Reputation: 1548
I've used Statement for this issue.
stmnt = conn.createStatement();
conn.setAutoCommit(false);
stmnt.addBatch("insert statement for categories");
stmnt.addBatch("insert statement for skins");
stmnt.addBatch("insert statement for CategorySkins");
...
stmnt.executeBatch();
conn.commit();
Upvotes: 3