on 02-18-2022 1:01 PM
Hello,
I needed an entity annotated with @cds.persistence.skip where the output is fully calculated in the handler.
Now, from the non-persistent entity it would be great to still be able to have an association to a usual, persisted entity. The main reason for that being Fiori Element navigations, otherwise we would have to do a freestyle implementation which is more effort and would not really be required.
It is straight forward to model it in cds and everything starts up properly but on request, I get a runtime error (SQLITE_ERROR: no such table:), so it seems that CAP wants to join to persistent table with the calculated entity where no table exists.
Is there any annotation or something to get around this?
Thanks,
Daniel
Example (might have syntax errors, just to make the idea more visual):
entity PersistedEntity {
key mykey: Integer,
anyField: String
}
@cds.persistence.skip
entity TransientEntity {
key mykey: Integer,
anyCalculatedField: String,
anyForeignKey : Integer,
persisted : Association to PersistedEntity
on persisted.anyField = $self.anyForeignKey
}
Its been 2 years but i thought why shouldnt i answer anyway? Perhaps it might help someone
These annotations seem correct (on first glance, i havent tested) and should work properly.
Heres where you went wrong: the annotation "@cds.persistence.skip" won't modify whatever query you send to your Remote Service / Database.
For this you would need to implement your own custom Handler:
something like this if you know what i mean
this.on("READ", "TransientEntity", async (req) => {
let oTransientEntity=this.calculateYourTransientEntity() //returns{anyCalculatedField:"Value"}
let oPersistedEntity=await cds.run(Select(["anyField"]).from("PersistedEntity"))
oTransientEntity.persisted=oPersistedEntity
return oTransientEntity
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.