Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Rajan Nath

Greenhorn
+ Follow
since Nov 27, 2007
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 Rajan Nath

I am using spring's getHibernateTemplate().find(tmp,parms), where in tmp when I passes hql it works, but when I passes native sql it failed.
can any one pl. tell, whether this method support native sql or not. I have written query in DaoImpl only.

The query I am using contains subquery and From clause query.thows exception 'org.hibernate.hql.ast.QuerySyntaxException: unexpected token' giving location from where next select start

Thanks,
Raj
[ August 21, 2008: Message edited by: Rajan Nath ]
Thanks once again Mark,Now I can go on right direction.
just check the spring jars are available in the lib of your war file.
One more thing due to listner in web.xml file, ApplicationContext.xml loaded in application. But you can write all the configuration details of context file, in -servlet.xml file, and with out listener details can be loaded in application.
Thanks Mark for prompt reply,
Let me try to explain the scenario,
I have one Message table
---------------

my requirement like if user creates a message then one row should be inserted in History table containing only HistoryId and MessageId.
if the same message (Name and Subject) edited by the user then two records should be inserted in History Table
Like
HistoryId MessageId ChangeValue
------- --------- ---------
1     1
-- | -- | ----
2     1    NewName
--- | ---- | ---------
3     1    NewSubject
--- ---- | ----------

where as in Message table one record inserted and then same record updated

So I am trying to implement one-to-many association.If I am using inverse, at the time of update I know the messageId so set the messageId in History object and set the History object in Message, then message updated.
But for Insert (new records in Message)I can't get messageId, as Message is going to save first time. and after save in Message table, 1 record is inserted in History with null value in MessageId column (I had kept not null false for messageId)
Any suggestion ,is it possible to insert in child table for save or update in Parent table
Thanks in advance

[ July 05, 2008: Message edited by: Rajan Nath ]

[ July 05, 2008: Message edited by: Rajan Nath ]
[ July 06, 2008: Message edited by: Rajan Nath ]
I had also gone through such scenario,if you add two bid (2 child object) then two insert and two update statement will execute, if one bid added then one insert and update statement will execute
I have a requirement to store histroy of message table. means I can create message or update message, when ever I create/update message, some records should also stroed in History table (means in update also , a new row should be insert in histroy)
I am trying to implement through one-to-many relation,as if we change name & subject i.e.two attributes,two row will be entered in history table ( many folks in this forum suggested to use bidirectional,that i have used even I require unidirectional)

the entry in hbm files are like

<?xml version="1.0"?>
<hibernate-mapping package="nl.inspiring.hibernate.test" default-access="field">
<class name="Message">
<id name="messageId">
<generator class="native"/>
</id>
<property name="name" column="name"/>
<property name="subject" column="sub"/>
<set name="histories" cascade="save-update" inverse="true"/>
<key column="messageId" />
<one-to-many class="History"/>
</set>
</class>
<class name="History">
<id name="historyId">
<generator class="native"/>
</id>
<property name="name" unique="true"/>
<many-to-one name="message" column="messageId" class="Message"/>
</class>
</hibernate-mapping>

If am using inverse true, in log only reuired no. of insert queries execute, but messageId comes null when records insert in Message, on update it is fine as I have that time messageId.
If I am not using inverse, along with insert update queries also executes, for first insert it working fine but for update new records properly inserted but the first record (which is edited now) modified with null in History table.

Any suggestion, how to deal with, if I want every time insert record in child on save or update inparent table (using one-to-many)

Thanks,
Raj

[ July 05, 2008: Message edited by: Rajan Nath ]

[ July 05, 2008: Message edited by: Rajan Nath ]
[ July 05, 2008: Message edited by: Rajan Nath ]
can any body tell, how exactly commandName works in <form:form>
I had used in jsp following
<form:form name="first" id="first" action="${pageContext.request.contextPath}/FirstController.do" commandName="firstCmd1">

in servlet.xml my entry is
<property name="commandName" value="firstCmd1" />

it is working , I want to know how it knows about the exact command object becuase name of my commandObject is "firstCmd"

the object of which I created in formBackingObject

thanks
entries in my hbm.xml like that



if I not use batch-size then multiple select queries executes.e.g. if for 100 mgd_id, 100 select queries execute for Art class.
If I use batch-size = 40 then I for 100 msg_id , 3 select query executes for Art class.

On console, what I found if you are not using batch-size the select query executes like select 1,2 from (table name)where id = ?
where as if use batch size then select query will be like select 1,2 from (table name)where id in(?,?) where No.of ? is no. of batch size.
can any body have idea that using batch-size how much improves performance or any side effect.

Thanks,
Raj
Thanks Cameron,
I am using the show_sql . The query generated I am able to find out but the query is not contains any thing due to which only 10 records fetched.
Can any body send how exactly the sample query will generate by using setMaxResult
I am using criteria, for pagination. The application get slow as for every page it brings all the records although (through display tag) only 10 records displayed.
when I used Criteria.setMaxResults(10), it brings only 10 records, I want to know is Hibernated firing query to bring only 10 records from database.
I am not able to see in any thing related with that in generated HQL.

Thanks
Raj
I am using criteria and my query is build like
select name from
(Family fp join UserProfile oup on fp.FamilyID = oup.familyid)
which is working.

I want to build like this
select name from
(Family fp left outer join UserProfile oup on fp.FamilyID = oup.familyid)
which I am not to implement
any way to implement, some one suggeted to use "FetchMode.JOIN" but ,I am using
"Criteria.createAlias("userProfile", "userProfileAlias");"
"Criteria.setFetchMode("userProfileAlias",FetchMode.JOIN );"
but still outer join not working
I have a one-to-one relationship in hbm

<one-to-one name="userProfile" class="UserProfile" lazy="false" outer-join="true" />

as I want even if no matching id is found null should come, but still left join working. I can not set any setting for outer-join in configuration file as it will applicable for all .

Thanks in advance
you might be using lazy="true" in hbm and then try to use that object. You can change it to false but then performance may take a hit
Hi,
I am trying to stop some unwanted sql query execution due relation in .hbm.xml

By using lazy="proxy" the sql query for that class not executed but if I used both 'not-found="ignore" lazy="proxy"' then it can not stop the execution of query

My entry in .hbm.xml is like

<many-to-one name="state" class="com.ind.model.CodeValue" not-found="ignore" lazy="proxy">
<column name="State" not-null="false" />

the select query also executes for CodeValue
</many-to-one>
due to which for every require select query , query for code value also executed resulting a performance hit.

Thanks & Regards,
Raj
[ March 18, 2008: Message edited by: Rajan Nath ]
Thanks Edvins,

Your reference helped me lot. I am now able to find the string ,sample code I have used given below

List question = new ArrayList();
Iterator itr= messFamily.iterator();
while(itr.hasNext()){
Object [] tuple =(Object []) itr.next();
String tmp = tuple[0].toString();
String tmp1 = tuple[1].toString();

question.add(tmp);
}