-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Dynamic SQL Preview fails with MYSQL Set Datatype
PostPosted: Wed Mar 03, 2010 10:55 am 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
In the Hibernate perspective, I successfully create a configuration, attach to my database, etc.
I create mappings, the mappings work. I write an HQL query in the HQL query window. The query is fairly complicated, but executes successfully from that window. But the Hibernate Dynamic SQL preview shows "Session factory not created for configuration:hibernate". No error appears in the Eclipse Error Log window.

Code:
   from NewRouteSchedule as r
      inner join fetch r.routeScheduleTimeslots as ts
         where ts.endingHour =
             (select min(rs.endingHour) from RouteScheduleTimeslot as rs
                   where rs.newRouteSchedule.id = ts.newRouteSchedule.id
                   and hour(current_time) <= rs.endingHour)
         and r.defaultFor like concat('%',dayname(current_date),'%')
         and r.userGroupId = :userGroupId   


My suspicion is that the defaultFor is what's throwing it off.

It is mapped as follows:

Code:
        <property name="defaultFor" type="string">
            <column name="DefaultFor" length="72" />
        </property>


But in the database (MYSQL 5.1 and 4.21) the table schema uses the MYSQL Set datatype:

Code:
CREATE TABLE `NewRouteSchedule` (
  `RouteScheduleID` int(10) NOT NULL default '0',
  `UserGroupID` int(10) NOT NULL default '0',
  `ExceptionDate` date default NULL,
  `DefaultFor` set('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') default NULL,
  PRIMARY KEY  (`RouteScheduleID`),
  KEY `UserGroupID` (`UserGroupID`),
  CONSTRAINT `NewRouteSchedule_ibfk_1` FOREIGN KEY (`UserGroupID`) REFERENCES `UserGroups` (`UserGroupID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1


Again, this query works successfully in both the Hibernate Tools HQL window and in the field, but simply fails to show the SQL.

Other queries do not have this problem. Is this a bug? You would think if the plugin could execute the query successfully, it could generate the SQL in the window.


Top
 Profile  
 
 Post subject: Re: Hibernate Dynamic SQL Preview fails with MYSQL Set Datatype
PostPosted: Thu Mar 04, 2010 12:12 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
Thanks. Let me know if I can help with more detail.


Top
 Profile  
 
 Post subject: Re: Hibernate Dynamic SQL Preview fails with MYSQL Set Datatype
PostPosted: Thu Mar 04, 2010 1:11 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
I'll do you one better. I'll give you the data. There isn't a lot.

Do you have my email address? If I can get yours I will send you what you need but I'd rather not post it here.


Top
 Profile  
 
 Post subject: Re: Hibernate Dynamic SQL Preview fails with MYSQL Set Datatype
PostPosted: Thu Mar 04, 2010 1:51 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
sent to your address.


Top
 Profile  
 
 Post subject: Re: Hibernate Dynamic SQL Preview fails with MYSQL Set Datatype
PostPosted: Fri Mar 05, 2010 3:55 pm 
Regular
Regular

Joined: Tue Oct 10, 2006 2:21 pm
Posts: 58
I sent you a reply by email yesterday to your email to me of yesterday. Did you get it?

Thanks.
Please resend to stevecoh1 AT gmail.com. Corporate email blocked your zip attachment.

I am not seeing anything that would account for the fact that the query itself works. If the mapping was wrong, wouldn't the query itself have failed?

I also sent you my hibernate.cfg.xml (via your email address)

The hibernate.cfg xml lives in /src/main/resources. the *.hbm/xml files live in /src/main/resources/com/att/relay/router/data/pojo. The class files live on the same subpath under /src/main/java.

Maybe this explains it why you had to change the class name specifications in the from clauses. Otherwise, I don't see what changes you made. I still don't understand what you think the problem is.

Steve


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.