Article table, which has all article related information.
A article can have one or more attachments, stored in article_attachments table.
Article_attachments has composite key for which we have articleAttachmentsId bean.
Following is the mapping in hbm.xml file:
articleattachments and articleattachmentsid bean are as follows:
I know the articleId and attachmentname and would like to retrieve the ATTACHMENT from the table. I wrote the following code:
I get the following exception:
Dont understand y it is searching for articleId in articleAttachments table, when i have created an alias? also trying to see if there is a resolution to this problem.
Please help. Any ideas.
Thank you!
Jayashree.
SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
The articleId is present in ArticleAttachmentsId bean, a composite key in article_attachments table.
If I were to remove the alias, how would I let the bean know to look for articleId and attachment name in articleattachmentsid bean.
The attachment itself , a byte[] is in articleattachments bean.
JayaSiji Gopal wrote:The articleId is present in ArticleAttachmentsId bean, a composite key in article_attachments table.
If I were to remove the alias, how would I let the bean know to look for articleId and attachment name in articleattachmentsid bean.
The attachment itself , a byte[] is in articleattachments bean.
I also tried this approach:
Here again i get the same exception as above.
because you have it mapped directly in the ArticleAttaments class as a composite id, so the id property is already there.
Have you removed it, detachedcriteria.createAlias("id", "id");
from your code and tried it yet?
Mark
JayaSiji Gopal
Ranch Hand
Joined: Sep 27, 2004
Posts: 303
posted
0
Ok..i do understand what you are saying...but if you remove the alias, how would i supply articleId & attachmentName as restrictions to the detached criteria.
I tried :
It still tries to look for articleId in articleAttachments, whereas it is actually present in ArticleAttachmentsId.