Is it possible to pass just the ID of the referenc...
# exposed
m
Is it possible to pass just the ID of the referenced objects when creating an instance of that dao? When using the Dao.new Method, it wants me to pass the Dao objects for the foereign key columns.
c
Hi @Marc If you don't have access to the referenced entity object in order to pass it to the
Reference
setter, you can use its id to try and retrieve the entity from the cache first.
EntityClass.findById(id: ID): T?
searches the cache first then runs a search query if the entity was not found there.
EntityClass[id]
does the same except it throws an
EntityNotFoundException
instead of returning
null
. While
EntityClass.testCache(id: EntityID<ID>): T?
will only search the cache.
👍 1