SQLContainer Reference ForeignKey

Hello there,

I just have started trying out the SQLContainer. All worked fine and I was able to write into my SQL-db with Container.commit()
But I don’t understand how to handle a foreignKey-relation between two tables/containers. Lets say there is a book table that has an “author_id” referencing to a author table. Then I can set the values like following: [code]

Object id = bookContainer.addItem();
bookContainer.getContainerProperty(id, “title”).setValue(book.getTitle());
bookContainer.getContainerProperty(id, “price”).setValue(book.getPrice());

Object id_a = authorContainer.addItem();
authorContainer.getContainerProperty(id_a, “first_name”).setValue(book.getAuthor().getFirstName);
authorContainer.getContainerProperty(id_a, “last_name”).setValue(book.getAuthor().getLastName);

[/code]
The
id_author
is primary key in the author-table and set via AutoIncrement in MySQL. So how do I tell the
bookContainer
to fill
author
with the id that will be generated by MySQL for the new author?

I tried the following, but it does not work: [code]

authorContainer.setReferencedItem(“id_author”, “author”, bookContainer);
bookContainer.addReference(authorContainer, “author”, “id_author”);
bookContainer.getContainerProperty(id, “author”).setValue(bookContainer.getReferencedItem(“id_author”, authorContainer));

[/code]
There is the error-message:
java.lang.IllegalArgumentException: Reference to the given SQLContainer not defined.