Win a copy of Spring Boot in Practice this week in the Spring forum!

Mahesh Gurav

Greenhorn
+ Follow
since Oct 18, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mahesh Gurav

Got the explanation ,you can see it at..
web page
15 years ago
class Trickytest {
public static void main ( String args [ ] ) {
int i = 10 ; // line 1
i = ++i ; // line 2
System.out.println("After 1st increment: "+i);
i = i++ ;
System.out.println("After 2nd increment: "+i);
i=i++;
System.out.println("After 3rd increment: "+i);
i=i++;
System.out.println("After 4th increment: "+i);
i=i++;
System.out.println("After 5th increment: "+i);

System.out.println ("value of "+ i ); // line 4
}
}

This prints value of i 11 each time ,i know i++ first assigns value and then increment i & ++i first assign and then increment i.But i need explanation because if i use j=i++;it prints incremented value..
15 years ago
Any one came across such requirement ,where you have to generate .hbm.xml files from database schema.Currently i am able to generate the .hbm.xml files according to tables but those files are not including lazy,cascade attributes.I am using hibernate tool.
Any suggetions.
hi pascal,
i have posted my query in some other thread after some code change ,now scenario is as follows,
setMaxResults() & setFirstResult().
If 100 records are fetched,25 records per page i want to show it like
<prev 1 2 3 4 next> ,i can not determine how many page numbers i sholuld show if i used above mentioned two methods as they limit result size itself.
What should i do to get size of result according to which i will show pageNumbers & on click of each number i will fetch & show query result of that page by using setFirstResult() & setMaxResults().
i am using struts-hibernate3,& criteria in hibernate.
"One fellow answered to fire another query to take total count".
My question is,Is there any other option available in criteria API to get total count of reultsize.
Because DB interaction is twice if i do as the above answer(in "") suggests.
Any Suggestions!!! ,
I think my query is fine & i m using postgreSQL Database,it is result size which hampers the performance .
MAHESH
Hi David & miguel ,
I am also facing same problem i tried using setFirstResult() & setMaxResult as well.But my requirement is slightely different.
If 100 records are fetched,25 records per page i want to show it like
<prev 1 2 3 4 next> ,i can not determine how many page numbers i sholuld show if i used above mentioned two methods as they limit result size itself.
What should i do to get size of result according to which i will show pageNumbers & on click of each number i will fetch & show query result of that page by using setFirstResult() & setMaxResults().
i am using struts-hibernate3,& criteria in hibernate.
Any Help!!! :roll:
MAHESH
anyone there,

I am using this chunk of code now ,i want to paginate the result.still
setFirstResult(10)is working fine but criteria.setFetchSize(500); is
not.Can anyone tell right way to use setFetchSize()& setFirstResult().
MAHESH
please give .hbm.xml & also details of database you are using.
hi,
i am using hibernate 3,& criteria API in it.I am searching members in DB on certain criteria & paginating the search result.Now problem is that when i search without any criteria query will fetch all data from table(obvious) .So query fetched more than 5000 members,which is slowing down the performance.i tried setMaxResult(500)but still prob is there.Any help available,how to use setMaxResult() or any other way for the prob.
Thnx in advance
If you are using c3p0 connection pooling this link will help.If a connection is unused it will be closed after certain time interval.
http://www.hibernate.org/214.html
You can write database schema name as an attribute in XX.hbm.xml file as follows.
<hibernate-mapping>
<class name="com.abc" schema="cr" table="AB_C">
--
</class>
</hibernate-mapping>
hope these URLS help u,
HibernateHelp::
ObjectStates.: etails
1)http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html
Criteria query & example:
1.)http://www.roseindia.net/hibernate/criteriaqueries.shtml
2.)http://www.devx.com/Java/Article/28754/1954?pf=true
Spring with hibernate
http://www-128.ibm.com/developerworks/web/library/wa-spring2/
1)Joins::
http://www.hibernate.org/hib_docs/v3/reference/en/html/associations.html
2)Deletion::
http://www.hibernate.org/117.html?cmd=diffhist&histnode=263

1)http://www.cs.bham.ac.uk/~aps/syllabi/2004_2005/issws/h03/hibernate.html
3)http://www.hibernate.org/hib_docs/reference/en/html/performance.html
4)http://jroller.com/page/wakaleo?entry=the_hibernate_criteria_api
5)http://www.hibernate.org/hib_docs/v3/api/org/hibernate/class-use/HibernateException.html#org.hibernate.cache
6)http://www.devx.com/dbzone/Article/29685/
Mark,
I think ben is asking Question about hibernate and u have given answer with reference to EJB transaction,i hope hibernate transaction are also work on the same rules.
If ben is asking about concurrency issue & according to u if hibernate is handling this issue by transaction only,then what is Pessimistic locking & optimistic locking.Can you elaborate the point.
refrence for locking mechanism:Hibernate in Action.Chapter 5.1.7
Thanks

entities are not getting deleted. When i check the database they are still there


You are commiting transaction by tx.commit(); but to check whether your transaction got commited or rolled back,Use tx.wasCommitted()& tx.wasRolleBack() which returns boolean status whether your transaction commited or rolledBack.
Further entity you want to delete is involved in cascad relationship with other object??if so it is getting resaved.If it is collection you will get documentation on net easily on this issue.

if there is two records for that id in child table.

when i display iam displaying two rows but the problem is first row printed twice. and the second original row is not showing. it means it overwrite the output with first record


override equals method in child bo as shown below,two different rows will be there when u print.
public boolean equals(Object obj) {
Child batch = (Child ) obj;
return this.batchID.equals(batch.getBatchID()) ? true : false;
}
where batchID is PK of child table.
If you are beginner this site will give u many simple examples.
web page
The following link will help you to understand Criteria api in hibernate3,
http://www.devx.com/Java/Article/28754/1954?pf=true
Try it,
Mahesh