Unable to get the correct ids from the hibernate query results
by chand sekhar
hi,
Here I am facing a problem while retriving the data from the hibernate POJO, once after making query.
Folloing is the code
DataBase Table.
V_SEARCH_CUSTOMER
CUSTOMER_ID CUSTOMER_NAME VENDOR_ID
1 TestCustomer 1
1 TestCustomer 2
1 TestCustomer 3
Java Code :
Using Hibernate when I search for 'CUSTOMER_NAME ' with 'TestCustomer' it's returning three rows but it's not giving the correct VENDOR_IDs. I am getting the result as follows
CUSTOMER_ID CUSTOMER_NAME VENDOR_ID
1 TestCustomer 1
1 TestCustomer 1
1 TestCustomer 1
When I run the sql qury generated by the Hibernate in the DbVissualizer it's giving the exact results.
I am facing the problem when I iterate though the query results.
Can any body help to get the correct vendor IDs
Thanks,
Chandu
____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
17 years, 7 months
[Hibernate-JIRA] Created: (HBX-941) NetBeans:NullPointerException thrown when creating tables.
by Sadi Melbouci (JIRA)
NetBeans:NullPointerException thrown when creating tables.
----------------------------------------------------------
Key: HBX-941
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-941
Project: Hibernate Tools
Issue Type: Bug
Components: ant
Affects Versions: 3.2beta8
Environment: OS: Linux FC6 Kernel: 2.6.19
DB: Derby: 10.2
Hibernate: 3.2
Reporter: Sadi Melbouci
Using the Hibernate plugin for NetBeans. Created the Hibernate Beans using the hibernate extension.
I was able to create the hbm.xml files.
In Hibernate Extension provides a way to create the DB from the hbm.xml files. When trying to do, an exception is throw:
java.lang.IllegalStateException: java.lang.NullPointerException
at sf.netbeans.nbxdoclet.hibernate.HibernatePanel.createDatabase(HibernatePanel.java:454)
at sf.netbeans.nbxdoclet.hibernate.HibernateCreateTableAction$1.run(HibernateCreateTableAction.java:54)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:499)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:932)
Caused by: java.lang.NullPointerException
at sf.netbeans.nbxdoclet.hibernate.HibernatePanel.createDatabase(HibernatePanel.java:445)
... 3 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 7 months
[Hibernate-JIRA] Created: (HHH-2618) Hibernate 3.2.4GA incompatiable with MySQL by using JPA
by Anthony Tam (JIRA)
Hibernate 3.2.4GA incompatiable with MySQL by using JPA
-------------------------------------------------------
Key: HHH-2618
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2618
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4
Environment: Hibernate 3.2.4GA
MySQL 4.0.20-standard
Reporter: Anthony Tam
I have downloaded the HelloWorld example and try to use Hibernate. I have changed the persistence.xml to use the MySQL database. The configuration I changed are
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://(mysql database)" />
<property name="hibernate.connection.username" value="username" />
<property name="hibernate.connection.password" value="password" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
When I am using the Hibernate core shipped with the example, that is version 3.2.0.cr5, it works totally fine. After that, I download the latest Hibernate core from your website and replace the hibernate3.jar with the latest one, I encounter the an error when I try to presist the Message object into the database.
The error is a SQLError bounced from MySQL saying that the field of ID is not supplied. When I turn on the SQL debug, I found that in version 3.2.0.cr5, the ID field is set to NULL and in version 3.2.4GA, the ID field is ?.
I can figure a work around to tempory fix this issue, I use the annotation
@org.hibernate.annotations.Entity(
dynamicInsert = true
)
to ask hibernate to dunamic generate the SQL statment and then the ID field will not be supplied in the insert SQL.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 7 months
[Hibernate-JIRA] Commented: (HHH-952) Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
by Matthias Bayer (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-952?page=co... ]
Matthias Bayer commented on HHH-952:
------------------------------------
Hello Don,
thanks for your suggestion.The code above is only example code.
In our application there are al lot of services. These services return only DetachedCriteria objects. I provide only the services.
The class that building the criteria used these services.
main query:
MyService myService = new MyService (selection);
DetachedCriteria detCrit = myService.getSubSelect();
detCrit.setProjection(Projections.projectionList().add(Projections.property("identifier")));
// add to criteria object a subquery
addSubquery(detCrit, "myproperty");
....
> Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
> --------------------------------------------------------------------------------------------
>
> Key: HHH-952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-952
> Project: Hibernate3
> Issue Type: Patch
> Components: core
> Affects Versions: 3.1 beta 1, 3.1 beta 2
> Environment: 3.1beta1 with MS SQL 2000 via jTDS
> Reporter: John
> Priority: Critical
> Attachments: subquery-patch-311.txt, subquery-patch-313.txt, subquery-patch-31beta3.txt, subquery-patch.txt, subquery-patch.txt, SubqueryExpression.java
>
>
> The existing code in SubqueryExpression.java constructed a select statement but did not have any provisions for creating joins. Therefore, it was not possible using the criteria API to create an exists subselect that had a join, even though running the source DetachedCriteria alone works perfectly.
> For example, if this is the goal:
> select * from foo f
> where exists (select id from bar b join other o on b.o_id = o.id where o.prop = '123' and b.foo_id = f.id)
> One might try something like this:
> Criteria crit = session.createCriteria(Foo.class, fooAlias);
> DetachedCriteria barCrit = DetachedCriteria.forClass(Bar.class, barAlias);
> DetachedCriteria otherCrit = barCrit.createCriteria(Bar.OTHER_JOIN);
> otherCrit.add( Restrictions.eq(Other.PROP, "123") );
> barCrit.add( Restrictions.eqProperty( -- props to join to foo here --) );
> barCrit.setProjection( Projections.id() );
> crit.add( Subqueries.exists(barCrit) );
> However, the existing code generates something like the following, which gets an error with an unknown alias 'o':
> select * from foo f
> where exists (select id from bar b where o.prop = '123' and b.foo_id = f.id)
> This is also described here (at the end): http://forum.hibernate.org/viewtopic.php?t=942488
> The patch to SubqueryExpression.java fixes this to included the joins necessary for the filtering. This code was modeled (copied) off of code from CriteriaLoader. For me this works perfectly, but I don't understand the internals of this stuff enough to say how robust it is. Also included is a patch to the test case to enable testing of this, which was present but commented out. I did not change the contents of the test, which currently only attempts a joined subquery. This used to fail with an error, but now it works. The test does not check the results at all. (Inconsequential to the patch - Enrollment has two Ls.)
> -----side notes
> The patch file also has two other patches. The first increases the delay in BulkManipulationTest because I was getting inconsistent test results. I think that the precision on the version timestamp is not enough for 300 milliseconds delay to be enough to guarantee the test results. Also, in build.xml, there was a line that was meant to exclude the performance tests, but there was no **/*, on *, so they actually were not excluded. I changed this so the tests would complete in a reasonable amount of time. However, there is one other issue with testing that I worked around manually. After each test run, two databases (Users and Email) were left in the database. If I did not manually delete these then the number of failures on the next test run was different. This was really confusing until I figured it out because I was trying to make sure all the other testcases still passed with my patch, but even without the patch I was getting different results.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 7 months