[JBoss Seam] - Re: slow queries using lobs in entities
by johnray
I had this problem yesterday. I'm using postgresql and defined the field like:
byte[] contents = null;
This create a bytea (similar to a blob) field in the database. If I annotated it with @Lob then a uid field is created. and contents is stored in a different location in the database. I believe that either ways works and there are pro and cons to using either a bytea or uid. I personally just went with the bytea.
I also had problems getting lazy fetching to work. In order to get lazy fetching to work you have to "instrument' your class files. This involves running an ant task on your compiled .class file. The easier and possibly better way is to use a query that does a "select new". That way you don't have to instrument your class files. For your class you would do a query like
select new File(f.person,f.filename) from File f
The above query only loads the person and filename fields. In order to get it to work you need to have 2 constructors in your class. The regular no args one and the constructor that takes a person and filename which is called by the above query. The downside to this method is that it is read only. You can't make modifications to the File object loaded with a select new and then write it to the database.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017771#4017771
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017771
19Â years, 2Â months
[JBoss Seam] - Re: Remove from list using EntityHome
by petemuir
"lightbulb432" wrote : "petemuir" wrote : My best guess as to why it fails from what you've said is that by passing the instance through the datamodel like that it has become unmanaged so cannot be removed - you can check this by calling entityManager.contains(). Setting by Id rather than instance might just work (use it with my.getId rather than rowIndex).
|
| Where should I set the breakpoint in my debugger to do an entityManager.contains() check?
|
| Or if it's better to output a FacesMessage with this value, where should I put that debugging line?
I don't think there is anywhere really existing in EntityHome you can put that. So I guess you could subclass EntityHome and override remove and do it there. Or if you are really clever with your debugger you should be able to get it to run to evaluate that line without it being in your code ;)
anonymous wrote : anonymous wrote : And beware of the fact that a remove won't remove the entity from memory - it just detaches it from the persistence context.
|
| So the refreshed page after the delete would still show the removed entity in the list right? But if I look in my DB, am I correct to say I should no longer see it there (if things work correctly) even though it's still in memory?
|
| Next question is why does this happen - isn't entity-query EVENT-scoped, which means that on the next refresh it doesn't exist and has to hit the DB again?
|
| Thanks a lot.
It might do - it depends on how your contexts are set up, whether you refresh your lists etc. But yes, it should no longer be in the db.
IIRC EntityQuery is conversation scoped. So you would need to use removeFromStatefulContexts to ensure it is refreshed I think...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017761#4017761
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017761
19Â years, 2Â months