myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Galligan" <mailingli...@kgalligan.com>
Subject Re: h:dataTable on an object containing a Set generated by Hibernate
Date Thu, 31 Aug 2006 20:20:34 GMT
Speaking of which, you need to be careful with a setup like this.  I use
hibernate extensively to populate my tables, and there are several potential
issues.

1) Just converting a set to a List.  You're not going to guarantee the
ordering of the data on a postback.  So, you might select row #3, but the
row #3 you get when you get back to the server isn't the same anymore.
Problem.

2) You figure out the ordering issue, but data has changed since you showed
the page.  Lets say you sort by "end date" (or any other arbitrary value).
If somebody added a record since you got the page, and you select row #3,
its possible that row #3 will no longer be what you expect.

Possible solutions.

1) preserveDataModel on the tomahawk table.  This is a pretty cool thing, as
it keeps the data in the request.  However, this is also bad, because it
will attempt to serialize your dataset.  Somebody correct me if I'm wrong,
but will serializing that data cause the whole hibernate tree to be pulled
down by reachability?  Even if not, if you've accessed much of the data such
that the proxys have pulled the db data, you're still going to serialize a
lot of extra data.  I don't think this is a problem if you turn on server
side storage AND turn off serialization.  Not sure what that does to
replication if you try to run a cluster, though.  Session replication
requires serilization, so you would be right back where you started.

2) forceIdIndexFormula on tomahawk table.  For hibernate style stuff, I'd
suggest this.  Technically, you wouldn't even have to worry about problem #1
above.  It'll figure out what id to use.  However, for large datasets I
think this is bad.

3) You could always do the old standby.  Just print links with id params.
I'm leaning this way with more performance intensive situations.  We tend to
use new cool technologies, but sometimes the old stuff works just fine.

On 8/31/06, Mike Kienenberger <mkienenb@gmail.com> wrote:
>
> Actually, the restriction is "ordered", not list.
> There needs to be a way to get from table row #12 back to backing item
> #12.
>
>
> On 8/31/06, Frank Russo <frank.russo@fxall.com > wrote:
> > I didn't realize that was a restriction.
> >
> > Thanks for the feedback...
> >
> > Frank Russo
> > Senior Developer
> > FX Alliance, LLC
> >
> >
> > -----Original Message-----
> > From: Mike Kienenberger [mailto:mkienenb@gmail.com]
> > Sent: Thursday, August 31, 2006 2:51 PM
> > To: MyFaces Discussion
> > Subject: Re: h:dataTable on an object containing a Set generated by
> > Hibernate
> >
> > UIData Iterators require an ordered list as a value.   Sets are not
> > ordered.  You'll need to convert your Sets into a List first --  List
> > list = new ArrayList(Set);
> >
> > On 8/31/06, Frank Russo <frank.russo@fxall.com> wrote:
> > >
> > >
> > > Has anyone tried the following:
> > >
> > > I have an object that is managed by Hibernate. It contains a
> > > one-to-many relationship implemented as a Set. Hibernate actually
> > > creates an org.hibernate.collection.PersistentSet object. I have a
> > > dataTable on that Set as follows:
> > >
> > > <h:dataTable id="senderCompIDsTable"
> > >              var="compID"
> > >
> > > value="#{participantBean.participant.senderCompIDs}"
> > > >
> > >     <h:inputHidden id="senderParticipantID"
> > > value="#{compID.key.participantID}"/>
> > >     <h:column id="selectColumn" rendered="#{false}">
> > >         <f:facet name="header">&#160;</f:facet>
> > >         <h:selectBooleanCheckbox id="selectForDelete"
> > > value="#{compID.active}" />
> > >     </h:column>
> > >     <h:column id="senderCompIDColumn">
> > >         <f:facet name="header">SenderCompID</f:facet>
> > >         <h:inputText id="senderCompID"
> > value="#{compID.key.senderCompID}"/>
> > >     </h:column>
> > >     <h:column id="passwordColumn">
> > >         <f:facet name="header">Password</f:facet>
> > >         <h:inputSecret id="password" value="#{ compID.password}"/>
> > >     </h:column>
> > >     <f:facet name="footer">
> > >         <h:commandButton
> > >             action="#{participantBean.addSenderCompID }"
> > >             styleClass="linkButton"
> > >             value="Add"
> > >             onmouseover="this.className='linkButtonHover'"
> > >             onmouseout=" this.className='linkButton'"
> > >         />
> > >     </f:facet>
> > > </h:dataTable>
> > > When the dataTable renders, there are no rows in the table, even
> > > though there is at least one item in Set. The only row generated has
> > > one empty column. The header row doesn't even render. I have an
> > > h:message tag on my page, but no errors are showing there or in the
> > > log file. Something is not right, but I can't track it down. I have
> > > this working on another screen with similar objects without the one to
> >
> > > many in the hibernate, so I'm wondering if it has to do anything with
> > the hibernate Set.
> > >
> > > Has anyone worked with a similar configuration, or seen a problem like
>
> > this?
> > > If I'm not posting enough info, let me know what other info I can
> > post.
> > >
> > > Thanks...
> > >
> > >
> > > Frank Russo
> > > Senior Developer
> > > FX Alliance, LLC
> > > 900 Third Avenue, 3rd Floor
> > > New York, NY 10022
> > > 646.268.9949
> > >
> >
> >
> >
> >
>

Mime
View raw message