Hello!
Maybe i am blind, but i just cant find something which helps me.
Is it possible to read all records in an table into a map where the key is other than the pk-key of the table?
Much like the <map ..> in an hbm.xml but i do not have a parent-child association.
The table is simply the "root"-Table.
Since i cant find how to add such a <map ...> into my hbm.xml without a parent-child association, i have tried something else. But this wont work too:
Table:
id <= pk-key
path <= another uniq-index field
last-mod-date
file-checked
And would like to set the file-checked to false on startup,
then check every file and set the last-mod-date and true to file-checked. Sometimes a new record has to be inserted.
Now i thought about this:
Code:
List files = dbSession.createCriteria(db.File.class).list();
Iterator iterFiles = songs.iterator();
while (iterFiles.hasNext())
{
db.File file = (db.File) iterFiles.next();
file.setFileChecked(false);
dbSession.update(file);
}
iterate-through-files-dummy
{
Collection files = dbSession.filter(files, "where path = ?", path, Hibernate.STRING);
if (files.isEmpty())
{
db.File file = new db.File(next-id, path)
file.setLastModDate(filedate);
file.setFileChecked(true);
dbSession.save(file);
}
else
{
file.setLastModDate(filedate);
file.setFileChecked(true);
dbSession.update(file);
}
}
But dbSession.filter wont work. I know why (files is not a persistent collection), but can i fetch all records to suit these needs?
Thanks,
Mario