Re: Paradigm advice on working with hibernate in Simple Content Portlet
Can't say I'm in tune with Hibernate programming, or ever was. I once made a mess of using Hibernate to store and load the login timestamp.
That said, were I in your shoes I'd be looking at Hibernate's lazy-loading features and seeing if I could get it to understand that the attachment part of the data should only be materialized when actually touched. I *think* Hibernate has magic annotations for this kind of case.
On Wednesday, October 30, 2019 at 8:49:40 AM UTC-5, Toby Archer wrote:
A while back I made an attachments manager for the <a href="https://github.com/Jasig/SimpleContentPortlet" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FJasig%2FSimpleContentPortlet\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-LWZekaRm5lTsLiKfTYCmCvzpAA';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FJasig%2FSimpleContentPortlet\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH-LWZekaRm5lTsLiKfTYCmCvzpAA';return true;">Simple Content Portlet to allow our marketing staff to upload arbitrary files to the portal and receive a link to them. It had some minor flaws, like not knowing how many attachments there were in total and so not knowing how to paginate properly, but it worked well enough. Recently though we've run into another flaw of the portlet as I've designed it: It loads all the attachments at once. This wasn't an issue when the number of attachments was small, but now we have passed 2500 attachments and that means loading this portlet requires loading 3+gb of data from the database and then promptly dumping it.
This is where I need some advice, I've always said Java isn't my first language and Hibernate is particularly so not my style of programming. If I was doing this manually by requesting the row from SQL I would just leave off the bdata column and only load the metadata. But just leaving off one column does not seem to be a straight forward concept in Hibernate. Before I hack something together I figured I'd ask people a little more in tune with this style of programming, what is the recommended way of achieving this?