| Handling files using lob in entity [message #638290] |
Wed, 10 November 2010 12:29  |
Arun Joy Messages: 10 Registered: July 2010 |
Junior Member |
|
|
This is my situation.
I want to store @lob in another entity class so that they wont get loaded when i load my entity class ( I know about lazy loading option but cannot use that option). Then maybe i can link a lob in this way without eagerly loading it.
@Entity
public class myClass
{
String fileClassId;
}
@Entity
public class FileClass
{
@id
String id;
@lob
byte[ ] mylob;
}
But the problem with this approach is no foreign key relationship is established between 'fileClassId' and 'id' .
Is there any way to establish it, without causing mylob to load eagerly ? ( and..Lazy loading is not an option for me)
Thanks in advance
|
|
|
| Re: Handling files using lob in entity [message #638556 is a reply to message #638290] |
Thu, 11 November 2010 10:55  |
James Sutherland Messages: 1844 Registered: July 2009 |
Senior Member |
|
|
You should just define a OneToOne to the lob entity.
@Entity
public class MyClass
{
@OneToOne(fetch=LAZY)
FileClass fileClass;
}
Otherwise you will need to query for the lob directly.
If you are just talking about schema creation, then you can add the foreign key constraint yourself, such as in a SessionCustomizer, or your own ddl scripts.
James : Wiki : Book : Blog
|
|
|
Powered by
FUDForum. Page generated in 0.01627 seconds