Re: [Wicket-user] Frustracted with JDBC...
I'd look for something like auto-commit inserting itself between these two lines. result = (SpecChangeModelObject) criteria.uniqueResult(); assertNotNull("SpecChangeModelObject should not be null", result); but that's just my best guess. Scott - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Frustracted with JDBC...
igor.vaynberg wrote: > > you do know that session.load() will return a proxy even if the object > doesnt exist, where as session.get() will return null. > > -igor > Yeah, but that really doesn't apply to this sceanrio. I KNOW that there is data. I KNOW that with either driver, when I use a Criteria object I do get the non-empty set. I KNOW that with one driver, when I use load() I get a non-empty set, but with the other driver it returns an empty set. I swear, the ONLY change that I make is to switch the JDBC driver class and adjust the connection URL. I know that it works because I do get *some* data, just not all of it. Chuck -- View this message in context: http://www.nabble.com/Frustracted-with-JDBC...-tf3375802.html#a9399846 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Frustracted with JDBC...
you do know that session.load() will return a proxy even if the object doesnt exist, where as session.get() will return null. -igor On 3/9/07, ChuckDeal <[EMAIL PROTECTED]> wrote: Scott Swank wrote: > > If you have lazy-loaded objects in your graph then they are initially > populated with Hibernate proxies and only resolved from the database > when you access them in your application code. I imagine that in one > case the Hibernate transaction is being closed before you have walked > the object graph far enough to retrieve all of the relevant objects, > while in the other case the transaction is still open and so Hibernate > can resolve the proxies. > > Try looking at any relevant settings on the jdbc drivers. We're using > jtds successfully (to the degree that anyone uses sql server > successfully). > > Scott > Yeah, I thought of that, but given the following code, you'll see that that isn't the case. Yet, the load() statement fails in my scenario. I made a very simple Parent and Child class test that doesn't suffer from this problem. But, my complex objects do. My guess is that I have a "bad" mapping, but my REAL concern is that with one driver it works and the other it doesn't! SpecChangeModelObject result; Session sess = hibernateSessionFactory.openSession(); Criteria criteria = sess.createCriteria(SpecChangeModelObject.class); criteria.add(Restrictions.idEq("{8D6A620D-B094-46CB-A6E7-34B4CE99EECD}")); result = (SpecChangeModelObject) criteria.uniqueResult(); assertNotNull("SpecChangeModelObject should not be null", result); assertNotNull("ResponsibleIndividuals should not be null", result.getResponsibleIndividuals()); assertFalse("ResponsibleIndividuals.isEmpty failed", result.getResponsibleIndividuals().isEmpty()); assertEquals("ResponsibleIndividuals.size failed", 2, result.getResponsibleIndividuals().size()); result = (SpecChangeModelObject) sess.load(SpecChangeModelObject.class, "{8D6A620D-B094-46CB-A6E7-34B4CE99EECD}"); assertNotNull("SpecChangeModelObject should not be null", result); // will fail on the next line! assertNotNull("ResponsibleIndividuals should not be null", result.getResponsibleIndividuals()); assertFalse("ResponsibleIndividuals.isEmpty failed", result.getResponsibleIndividuals().isEmpty()); assertEquals("ResponsibleIndividuals.size failed", 2, result.getResponsibleIndividuals().size()); sess.close(); Chuck -- View this message in context: http://www.nabble.com/Frustracted-with-JDBC...-tf3375802.html#a9399084 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Frustracted with JDBC...
Scott Swank wrote: > > If you have lazy-loaded objects in your graph then they are initially > populated with Hibernate proxies and only resolved from the database > when you access them in your application code. I imagine that in one > case the Hibernate transaction is being closed before you have walked > the object graph far enough to retrieve all of the relevant objects, > while in the other case the transaction is still open and so Hibernate > can resolve the proxies. > > Try looking at any relevant settings on the jdbc drivers. We're using > jtds successfully (to the degree that anyone uses sql server > successfully). > > Scott > Yeah, I thought of that, but given the following code, you'll see that that isn't the case. Yet, the load() statement fails in my scenario. I made a very simple Parent and Child class test that doesn't suffer from this problem. But, my complex objects do. My guess is that I have a "bad" mapping, but my REAL concern is that with one driver it works and the other it doesn't! SpecChangeModelObject result; Session sess = hibernateSessionFactory.openSession(); Criteria criteria = sess.createCriteria(SpecChangeModelObject.class); criteria.add(Restrictions.idEq("{8D6A620D-B094-46CB-A6E7-34B4CE99EECD}")); result = (SpecChangeModelObject) criteria.uniqueResult(); assertNotNull("SpecChangeModelObject should not be null", result); assertNotNull("ResponsibleIndividuals should not be null", result.getResponsibleIndividuals()); assertFalse("ResponsibleIndividuals.isEmpty failed", result.getResponsibleIndividuals().isEmpty()); assertEquals("ResponsibleIndividuals.size failed", 2, result.getResponsibleIndividuals().size()); result = (SpecChangeModelObject) sess.load(SpecChangeModelObject.class, "{8D6A620D-B094-46CB-A6E7-34B4CE99EECD}"); assertNotNull("SpecChangeModelObject should not be null", result); // will fail on the next line! assertNotNull("ResponsibleIndividuals should not be null", result.getResponsibleIndividuals()); assertFalse("ResponsibleIndividuals.isEmpty failed", result.getResponsibleIndividuals().isEmpty()); assertEquals("ResponsibleIndividuals.size failed", 2, result.getResponsibleIndividuals().size()); sess.close(); Chuck -- View this message in context: http://www.nabble.com/Frustracted-with-JDBC...-tf3375802.html#a9399084 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Frustracted with JDBC...
If you have lazy-loaded objects in your graph then they are initially populated with Hibernate proxies and only resolved from the database when you access them in your application code. I imagine that in one case the Hibernate transaction is being closed before you have walked the object graph far enough to retrieve all of the relevant objects, while in the other case the transaction is still open and so Hibernate can resolve the proxies. Try looking at any relevant settings on the jdbc drivers. We're using jtds successfully (to the degree that anyone uses sql server successfully). Scott On 3/9/07, ChuckDeal <[EMAIL PROTECTED]> wrote: > > I was able to narrow the problem scope a little. > > The difference is between getting a result from a Criteria object vs > Session.load(). > > With both drivers, using the criteria object gets a fully populated object > (with children) > With the JTurbo (JDBC 2.1) driver, Session.load returns the fully populated > object while jTDS (JDBC 3.0) returns only the parent! > > The problem with the model is that the DataBinder HibernateObjectModel uses > session.load()! So now my problem lies with Hibernate(?) and the difference > between those methods. I'm still interested in ideas if anyone has had > similar experiences with this. > > Chuck > > > > ChuckDeal wrote: > > > > I really don't know where to ask this, so I am trying here because someone > > may have encountered a similar problem... > > > > I use MSSQLServer 2000 and JTurbo (JDBC 2.1) driver. > > Wicket 1.3, Databinder 1.1 > > > > I ran into a case where my tables had triggers on them. Hibernate > > wouldn't let the update occur because it looked like I was updating too > > many rows. So, I modified the triggers to SET NOCOUNT ON at the beginning > > and SET NOCOUNT OFF at the end. Query Analyzer reports only one row > > updated, but now Hibernate gets ZERO rows. I assume that it is not > > Hibernate's fault, but the JDBC driver reporting the rowcount wrong. > > > > So, I had been planning on switching to the jTDS driver anyway (for when > > we switch to SQLServer 2005) so I try to hook that it. Not a big deal, > > fix the hibernate.cfg.xml and a simple JUNIT that uses a Session and > > Criteria returns the parent object and children collections just fine. > > Enter my code, Pages, Panels, HibernateObjectModels, etc. Now, I can't > > get ALL of the data to display only the parent object, the child > > collections appear as empty. Arghh! > > > > I know, I know... That's ridiculous, nothing changed but the driver! So, > > I added some code to the page constructor that did very much what the Unit > > test did and voila, it worked. I get a parent object with initialized > > collections. Yet, still when it comes time for the model to pull the > > collections off the parent, nothing! So, I simply switch back to the old > > driver and it starts working again. > > > > What could possibly be happening? The only real difference (besides the > > obvious fact that I am using two different drivers) is that one driver > > (the original is a JDBC 2.1) and the new driver (jTDS) is a JDBC 3.0. > > But, since I can pull data with the driver, that doesn't seem like it > > could be the problem. Have you ever encountered something so ridiculous > > as this? Why aren't the Models returning data for the children > > collections? Even when I get a handle to the parent object from the main > > model and call the collection directly it doesn't work! I set fetch=EAGER > > on the collection, no luck. I turned off second level cache, no luck. > > I'm very frustrated and am hoping you have some insight. > > > > n summary, > > using old JDBC 2.1 driver (JTurbo) Hibernate retrieves all data and models > > can display all data. > > Using new JDBC 3.0 (jTDS), Hibernate retrieves all data, but models only > > retrieve the parent data, not children! > > > > Thoughts? > > > > Chuck > > > > > > -- > View this message in context: > http://www.nabble.com/Frustracted-with-JDBC...-tf3375802.html#a9395214 > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ___ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > -- Scott Swank reformed mathematician - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.ph
Re: [Wicket-user] Frustracted with JDBC...
I was able to narrow the problem scope a little. The difference is between getting a result from a Criteria object vs Session.load(). With both drivers, using the criteria object gets a fully populated object (with children) With the JTurbo (JDBC 2.1) driver, Session.load returns the fully populated object while jTDS (JDBC 3.0) returns only the parent! The problem with the model is that the DataBinder HibernateObjectModel uses session.load()! So now my problem lies with Hibernate(?) and the difference between those methods. I'm still interested in ideas if anyone has had similar experiences with this. Chuck ChuckDeal wrote: > > I really don't know where to ask this, so I am trying here because someone > may have encountered a similar problem... > > I use MSSQLServer 2000 and JTurbo (JDBC 2.1) driver. > Wicket 1.3, Databinder 1.1 > > I ran into a case where my tables had triggers on them. Hibernate > wouldn't let the update occur because it looked like I was updating too > many rows. So, I modified the triggers to SET NOCOUNT ON at the beginning > and SET NOCOUNT OFF at the end. Query Analyzer reports only one row > updated, but now Hibernate gets ZERO rows. I assume that it is not > Hibernate's fault, but the JDBC driver reporting the rowcount wrong. > > So, I had been planning on switching to the jTDS driver anyway (for when > we switch to SQLServer 2005) so I try to hook that it. Not a big deal, > fix the hibernate.cfg.xml and a simple JUNIT that uses a Session and > Criteria returns the parent object and children collections just fine. > Enter my code, Pages, Panels, HibernateObjectModels, etc. Now, I can't > get ALL of the data to display only the parent object, the child > collections appear as empty. Arghh! > > I know, I know... That's ridiculous, nothing changed but the driver! So, > I added some code to the page constructor that did very much what the Unit > test did and voila, it worked. I get a parent object with initialized > collections. Yet, still when it comes time for the model to pull the > collections off the parent, nothing! So, I simply switch back to the old > driver and it starts working again. > > What could possibly be happening? The only real difference (besides the > obvious fact that I am using two different drivers) is that one driver > (the original is a JDBC 2.1) and the new driver (jTDS) is a JDBC 3.0. > But, since I can pull data with the driver, that doesn't seem like it > could be the problem. Have you ever encountered something so ridiculous > as this? Why aren't the Models returning data for the children > collections? Even when I get a handle to the parent object from the main > model and call the collection directly it doesn't work! I set fetch=EAGER > on the collection, no luck. I turned off second level cache, no luck. > I'm very frustrated and am hoping you have some insight. > > n summary, > using old JDBC 2.1 driver (JTurbo) Hibernate retrieves all data and models > can display all data. > Using new JDBC 3.0 (jTDS), Hibernate retrieves all data, but models only > retrieve the parent data, not children! > > Thoughts? > > Chuck > > -- View this message in context: http://www.nabble.com/Frustracted-with-JDBC...-tf3375802.html#a9395214 Sent from the Wicket - User mailing list archive at Nabble.com. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user