Bharath Gowda

Greenhorn
+ Follow
since Apr 15, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bharath Gowda

Hey Chandra,

Thanks for yor reply.

But I'm inserting a row into the base table then I'm trying to insert into the foreign key table...am I doing something wrong?
Hi Please find below mapping file and the code I'm using

<class name="com.mlb.eventportal.arch.businessobjects.TravelInfoBO" table="t_travel_info">
<id name="travelInfoId" column="travel_info_id">
<generator class="increment"/>
</id>

<many-to-one name="person" column="person_id"
class="com.mlb.eventportal.arch.businessobjects.PersonBO" cascade="save-update"/>

<property name="nationality" column="nationality" type="string"/>
<property name="passportNamePrimary" column="prim_passport_name" type="string"/>
<property name="passportNbrPrimary" column="prim_passport_nbr" type="string"/>
<property name="passportCountryPrimary" column="prim_passport_country" type="string"/>
<property name="passportExpPrimary" column="prim_passport_exp" type="date"/>
<property name="passportNameSecondary" column="sec_passport_name" type="string"/>
<property name="passportNbrSecondary" column="sec_passport_nbr" type="string"/>
<property name="passportCountrySecondary" column="sec_passport_country" type="string"/>
<property name="passportExpSecondary" column="sec_passport_exp" type="date"/>
<property name="greenCardSerNbr" column="green_card_ser_nbr" type="string"/>

data service to insert:

while ((travelInfoIt!= null) && (travelInfoIt.hasNext())) {
if (event == null) {
throw new MLBPortalException("No Event is populated");
}
travelInfo = (TravelInfoBO) travelInfoIt.next();
//session.lock(travelinfo, LockMode.NONE);
VisaStatusBO visastatus = travelInfo.getUsVisaStatus();
session.lock(visastatus, LockMode.NONE);

test Method.....
// Setup Travel Info
TravelInfoBO travelInfo = new TravelInfoBO();

Set travelInfos = new HashSet();

travelInfo.setPerson(person);
travelInfo.setTravelInfoId(4);
travelInfo.setNationality("Asian");
travelInfo.setSocialSecurityNbr("123456779");

VisaStatusBO usVisaStatus = new VisaStatusBO();
usVisaStatus.setVisaStatusId("1A");


//usVisaStatus.setDescription("Normal");
//usVisaStatus.setActive(true);
//usVisaStatus.setTsAdd(Calendar.getInstance().getTime());
//usVisaStatus.setTsUpdate(Calendar.getInstance().getTime());

travelInfo.setUsVisaStatus(usVisaStatus);
travelInfo.setRowSource("123");


when I set the TravelInfoId, I do not get any error as it executes the update query...
Hi,

I'm trying to insert data into 2 tables in Hibernate using session.save(). But the issue is one of the column value inserted(generated) to the first table should be inserted as a foreign key value to the second table.

In this case, the value generated in the first table is inserted to the second table when I update the existing row in the second table.

When I try to create a new row in the second table than I'm getting below error..Please let me know how to solve this issue.

SEVERE: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=3, TABLEID=85, COLNO=31, DRIVER=3.50.152
Nov 20, 2008 4:01:18 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not insert:
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2272)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:60)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at
Caused by: com.ibm.db2.jcc.b.lm: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=3, TABLEID=85, COLNO=31, DRIVER=3.50.152
at com.ibm.db2.jcc.b.wc.a(wc.java:575)
at com.ibm.db2.jcc.b.wc.a(wc.java:57)
at com.ibm.db2.jcc.b.wc.a(wc.java:126)
at com.ibm.db2.jcc.b.tk.b(tk.java:1593)
at com.ibm.db2.jcc.b.tk.c(tk.java:1576)
at com.ibm.db2.jcc.t4.db.k(db.java:353)
at com.ibm.db2.jcc.t4.db.a(db.java:59)
at com.ibm.db2.jcc.t4.t.a(t.java:50)
at com.ibm.db2.jcc.t4.tb.b(tb.java:200)
at com.ibm.db2.jcc.b.uk.Gb(uk.java:2355)
at com.ibm.db2.jcc.b.uk.e(uk.java:3129)
at com.ibm.db2.jcc.b.uk.e(uk.java:3238)
at com.ibm.db2.jcc.b.uk.zb(uk.java:568)
at com.ibm.db2.jcc.b.uk.executeUpdate(uk.java:551)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252)
... 14 more
Exception in thread "main" org.hibernate.exception.ConstraintViolationException: could not insert:
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2272)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:60)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at
Caused by: com.ibm.db2.jcc.b.lm: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=3, TABLEID=85, COLNO=31, DRIVER=3.50.152
at com.ibm.db2.jcc.b.wc.a(wc.java:575)
at com.ibm.db2.jcc.b.wc.a(wc.java:57)
at com.ibm.db2.jcc.b.wc.a(wc.java:126)
at com.ibm.db2.jcc.b.tk.b(tk.java:1593)
at com.ibm.db2.jcc.b.tk.c(tk.java:1576)
at com.ibm.db2.jcc.t4.db.k(db.java:353)
at com.ibm.db2.jcc.t4.db.a(db.java:59)
at com.ibm.db2.jcc.t4.t.a(t.java:50)
at com.ibm.db2.jcc.t4.tb.b(tb.java:200)
at com.ibm.db2.jcc.b.uk.Gb(uk.java:2355)
at com.ibm.db2.jcc.b.uk.e(uk.java:3129)
at com.ibm.db2.jcc.b.uk.e(uk.java:3238)
at com.ibm.db2.jcc.b.uk.zb(uk.java:568)
at com.ibm.db2.jcc.b.uk.executeUpdate(uk.java:551)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252)
... 14 more
Hi Jaikiran,

Thank you so much.

It works fine for me. What I see in the query is it converts the input value into lowercase in the where clause.
can you please help me understand how does I still get the correct results from the database?
some columns are boolean data type in the database.
Hi Jaikiran,

Thanks for your replay.

I've a simple criteria to search the database based on the name entered in the text field. I'm searching in only one table.
Below code works fine when I remove the ignore case criteria. when I add this example to the Criteria, it takes all the numeric fields in the tyable in the where clause of the criteria instead of name only. Please suggest

Example example = Example.create(person);
example.ignoreCase();

Criteria criteria=
session.createCriteria(PersonBO.class);

criteria.add(Expression.like("nameFirst","%" + nameFirst + "%"));
criteria.add(Expression.like("nameLast","%" + nameLast + "%"));
criteria.add(example);

Where clause from the query:

from
T_PERSONS this_
where
this_.NAME_FIRST like ?
and this_.NAME_LAST like ?
and (
this_.LAST_UPDATED_BY=?
and this_.CREDIT_CHECK_NEEDED=?
and this_.ACTIVE=?
Hi All,

How can I get all the case sensitive results from the database(IBM DB2 v8.1) using HQL

Thanks,
Bharath
Hi Dharmesh,

Thanks for your suggestion.
Since the action URL will have encoded url, I tried it and does not work that way. Please let me know if you have come across other ways of implementing it.
16 years ago
Hi,

I've created a column sortable table in a portlet JSP using Comparator. When i click on the table header I call a javascript function to sort the data by sending the sorting order and the column value. And the sorting method is in the portlet action class. Now the question is to call this sorting method in the javascript and refresh the table.

I'm using Basic JSR 168 portlet,IBM RAD 7.0 and IBM portal 6.0

Can anybody please help!!!


Thanks,
Bharath
16 years ago
Hi Afzal,

yes it works. Thank you.
16 years ago
JSP
Hi Bear,

There are 2 type of search need to be performed, so I have 2 radio buttons. on click of each radio i'll show the different jspf's which has tables to show the data.

Based on the radio the user has selected during the session, I need to show the jspf. so i'm using the c:if tag to check the user selected value
16 years ago
JSP
<@ is just a derivative as per JSP specifications. so try using <jsp:include> and change the name from JSPX.jspx to somexxx.jspx. please be informed that you need to use the file name and not the title to include the jspx in a jsp
16 years ago
JSP
I've 2 radio buttons as defined below

td>
<input type="radio" name="search" value="person" checked="checked">Person
</td>
<td>
<input type="radio" name="search" value="group" > Group
</td>

I need to show some jspf based on the selected radio button. so i've written the code as below.

<c:if test="$(sessionScope.)"> --- what should I write here to get the session value
<jsp:include page="page1.jspf"></jsp:include>
</c:if>
<c:if test="$(sessionScope.radio.search = 'group')">
<jsp:include page="page2.jspf"></jsp:include>
</c:if>
16 years ago
JSP
Thanks Cameron. We decided to use JSR 168 basic portlets instead of using struts portlets.
16 years ago
Hi,

I'm new to portlet development. I'm trying to send data from one struts portlet to another struts portlet but it is giving error.

struts-config.xml
************************************
<!-- Form Beans -->
<form-beans>
<form-bean name="SelectForm" type="com.gdnindia.strutsnav.forms.SelectForm">
</form-bean>
</form-beans>

<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>

<!-- Global Forwards -->
<global-forwards>
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action path="/SendData" type="com.gdnindia.strutsnav.actions.SendDataAction" name="SelectForm" scope="request">
<forward contextRelative="false" name="success" path="/successpage.jsp">
</forward>
</action>
</action-mappings>
***********************************************
index.jsp
********************************************
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<portlet efineObjects/>
<h3><br>
Select a Team:</h3>
<html:form action="/SendData">
<html:select property="selectedItem" onchange="this.form.submit();">
<html ption value="TeamA">Team A</html ption>
<html ption value="TeamB">Team B</html ption>
<html ption value="TeamC">Team C</html ption>
<html ption value="TeamD">Team D</html ption>
<table>
<tbody>

<tr>
<td align="left">SelectedItem:</td>
<td><c ut value="${sessionScope.selectedItem}" /></td>
</tr>

</tbody>
</table>
</html:select>
</html:form>
**********************************
successpage.jsp
************************************
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@page import="javax.portlet.PortletSession"%>

<portlet efineObjects />
<% PortletSession s = renderRequest.getPortletSession();
String data = (String) s.getAttribute("javax.portlet.request");
if (data == null || data.length() == 0)
data = "no data found"; %>
<h3>Team selected is:</h3>
<table>
<tbody>

<tr>
<td align="left">SelectedItem:</td>
<td><c ut value="${data}" /></td>
</tr>

</tbody>

</table>
***************************************
SendDataAction.java
**************************************
public class SendDataAction extends StrutsAction implements IStrutsPrepareRender

{

public ActionForward execute(ActionMapping mapping, ActionForm form, PortletRequest request, PortletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value

try {
System.out.println(" ---- Entering SendDataAction to retrive the value---");

PortletSession psession = request.getPortletSession();
//RenderRequest pReq = (RenderRequest) request
//.getAttribute("javax.portlet.request");
RenderResponse rRes = (RenderResponse) request
.getAttribute("javax.portlet.response");
//PortletConfig portletConfig = (PortletConfig) request.getAttribute("javax.portlet.config");

String teamname = request.getParameter("selectedItem");
System.out.println("***Team Name VALUE ***" + teamname);
psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE);
System.out.println("***Team Name VALUE ***" + psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE));
rRes.getPortletOutputStream();
System.out.println("***Leaving SendDataAction to retrive the value***");

} catch (Exception e) {

**************************************
SelectForm.java
************************************
public class SelectForm extends ActionForm

{

/**
*
*/
private static final long serialVersionUID = -6313074275445304102L;
private String SelectedItem = null;

/**
* Get SelectedItem
* @return String
*/
public String getSelectedItem() {
return SelectedItem;
}

/**
* Set SelectedItem
* @param <code>String</code>
*/
public void setSelectedItem(String s) {
this.SelectedItem = s;
}

}
**************************

I'm trying to do this from 2 days. but i'm getting "400 Invalid path /SendData was requested" error...I'm going crazy, Please let me know what is wrong with the implementation. I'm using IBM RAD 7.0, Websphere portal 6.0 server

Or if you have any sample code to implement this, please share it with me.
16 years ago