Maneessh saxena

Ranch Hand
+ Follow
since Oct 03, 2006
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 Maneessh saxena

Hi Ranchers,

Please refer the mapping and bean classes below.


===============================================
<hibernate-mapping>
<class name="com.test.beans.Employee" table="Employee">

<id name="empId" column="id">
<generator class="foreign">
<param name="property">department</param>
</generator>
</id>

<property name="name">
<column name="name" />
</property>


<one-to-one name="department" cascade="all"
class="com.test.beans.Department" constrained="true"></one-to-one>

</class>

<class name="com.test.beans.Department" table="Department">
<id name="Id" type="long" column="id" unsaved-value="0">
<generator class="increment" />
</id>

<property name="deptName" unique="true">
<column name="deptName" />
</property>
</class>

</hibernate-mapping>




=============================================


public class Department {
private long Id;
private String deptName;
.............................Gettr Setters.......

=============================================


public class Employee {
private String name;
private long empId;
Department department;
.............................Gettr Setters.......

=============================================




My Question is if Employee table is parent of Department as Employees compposes Department ? Or reverse is true i.e Department table is parent of Employee.

When I try session.save(employeeObject) assosiated Department Object also gets saved in Department table whereas this is not the case when I try session.save(department) as it only saves Department object.

Thanks & Regards
Maneesh Saxena






Tomasz Szymanski wrote:

But then... I bet it'll throw another exception, related to the order in which you're finishing the transaction. If it does, you'll probably figure out why.




hi Tomasz,

Thanks for your reply. Yes it givies error if a corresponding record is not there in department/Parent table. And that's what my question is, Is there any way that when I save employee/child and corresponding record is not there in department/Parent table, both the records for parent & child tables could save automatically. Please let me know in case my question is not clear.


Thanks & Regards
[size=18][size=12]hi Great Ranchers,

I’ve some doubt in Mapping Associations. Please refer the mapping and code below ….


<hibernate-mapping>
<class name="com.test.beans.Employee" table="employee">
<id name="empId" unsaved-value="0">
<generator class="increment" />
</id>

<many-to-one name="department" class="com.test.beans.Department"
cascade="all" column="employee_department">
</many-to-one>
<property name="name" />
</class>

<class name="com.test.beans.Department" table="department">

<id name="deptId" unsaved-value="0">
<generator class="increment" />
</id>

<property name="deptName"></property>
</class>

</hibernate-mapping>


Bean classes are as given below ……..


package com.test.beans;

public class Department {
private int deptId;

private String deptName;
……………………….Getter Setters.


And


package com.test.beans;

public class Employee {
private int empId;

private String name;

private Department department;
……………………….Getter Setters.

I tried the below code in main method to save an Employee object ….

Employee employee = new Employee();
employee.setName("Manish");
employee.setEmpId(1);

Department department = new Department();
department.setDeptName("BFSI");
department.setDeptId(1);

employee.setDepartment(department);

SessionFactory factory = new Configuration().configure()
.buildSessionFactory();

Session session = factory.openSession();

Transaction transaction = session.beginTransaction();

session.save(employee);

session.flush();

session.close();

transaction.commit();


I got the error given below …

Caused by: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`testhibernate/employee`, CONSTRAINT `FK4722E6AE8933862F` FOREIGN KEY (`employee_department`) REFERENCES `department` (`deptId`))
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1257)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:943)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
... 6 more


……..


At the time I tried to insert Employee details in employee table the department table was empty.

1) My understanding is:-
As I could not have any record in employee table which’s not corresponding to department table and since department table is empty hence the error comes.



2) Now if I’ve to insert some employees in employee table I’ll have to follow the steps given below.

(i) I’ll have to create department object with deptId value i.e existing in the department table (assuming department table is populated with some objects).
(ii) Now creating employee object and pass department object created in above step to setDepartment() method.
(iii) Now call session.save(employee).

Is that the way to insert employees in the employee table ?

IS there any way, when I save employee object then it’s associated department object is automatically saved provided it’s not there department table previously?
[/size][/size]
hi great Ranchers,

I wanna know that what are the factors that causes serialVersionUID of a class changed. I am really confused about this.

Thanks & Regards
9 years ago
Hi Great Ranchers,

I need your help as quick as possible. actually I've to prepare for an interview. As per the requirement JDK 1.5 Features in Multithreading is a must, which I've no idea for. I request you please give me useful, simple and small tutorial link as I've only one day to prepare this. By the way, I am good in Multithreading as far as jdk 1.4 is concerned.

Best Regards
Hi Great Ranchers,

I need to implement a table in the format given below ....

<webuijsf:table augmentTitle="false" id="" paginationControls="true" style="height: 48px; left: 48px; top: 48px; position: absolute; width: 695px" title="" width="695">
<webuijsf:tableRowGroup id="" rows="11" sourceData="#{SearchBean.beanList}" sourceVar="currentRow">

<webuijsf:tableColumn headerText="Type" id="type_Col">
<webuijsf:staticText id="type_id" text="#{currentRow.tableDataProvider.list[currentRow.tableRow.rowId].type}"/>
</webuijsf:tableColumn>

<webuijsf:tableColumn headerText="ID" id="id_Col">
<webuijsf:staticText id="id_id" text="#{currentRow.tableDataProvider.list[currentRow.tableRow.rowId].id}"/>
</webuijsf:tableColumn>

<webuijsf:tableColumn headerText="Locked" id="locked_Col1">
<webuijsf:staticText id="locked_id" text="#{currentRow.tableDataProvider.list[currentRow.tableRow.rowId].locked}"/>
</webuijsf:tableColumn>

</webuijsf:tableRowGroup>
</webuijsf:table>


Actually my requirement is that when I click on a perticular column then table needs to get sorted according to that column. Means if I click on "Type" column then table should get sorted according to "Type". Hope I made the requirement clear.

Please let me know the possible and easy way to do so .

Thanks & Regards
10 years ago
JSF
hi actualy I have getter and setter too. but still I am getting PropertyNotFoundException.
10 years ago
JSF
Why I am getting PropertyNotFoundException even if I have defined and initialized the bean property in the required bean class.

Error is::

Caused by: javax.faces.el.PropertyNotFoundException: Error getting property 'tableDataProvider' from bean of type com.cdms.beans.GFCIDSearch
at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:127)
at com.sun.rave.web.ui.faces.UIComponentPropertyResolver.getValue(UIComponentPropertyResolver.java:119)
at com.sun.rave.web.ui.faces.DataProviderPropertyResolver.getValue(DataProviderPropertyResolver.java:183)
…………

Jsp is :

<webuijsf:panelLayout id="GFCIDSearchPanel" style="height: 530px; margin-bottom: 3px; left: 0px; top: 0px; position: relative; width: 840px; -rave-layout: grid">
<webuijsf:table augmentTitle="false" id="gfcid_Req_table1" paginationControls="true" style="height: 48px; left: 48px; top: 24px; position: absolute"
title="GFCID Requests" width="695">
<webuijsf:tableRowGroup id="GFCIDen_table1_tableRowGroup1" rows="11" sourceData="#{GFCIDSearch.tableDataProvider}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Type" id="type_Col">
<webuijsf:staticText id="type_id" text="#{currentRow.tableDataProvider.list[currentRow.tableRow.rowId].GFCID_TYPE}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="ID" id="id_Col">

………

And backing bean class is

public class GFCIDSearch extends AbstractFragmentBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

/**
*

Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.


*/
private void _init() throws Exception {
}
// </editor-fold>

private ArrayList<GFCIDRequestsBean> gfcidReqBeanList = null;
private static transient TableDataProvider tableDataProvider = null;
…….

I am not getting that In spite of declering propert correctly I am getting PropertyNotFoundException. Please let me know why this error is coming...


Thanks & Regards





10 years ago
JSF

seb petterson wrote:In my web.xml file I have:
as well asBut still when I type in a url for a jsp file with the extension replaced for jsf the webserver returns "file not found".
I should mention that I have a boiled down version of my webapp working on a local tomcat instance. However, the target environment for the jsf enabled jsps is an existing webapplication in a WebSphere Application Server, and here it fails.

In the web.xml file there are also many elements declaring various filter-mappings and servlet-mappings, including for the url-pattern /*, can this be the cause of the mapping not working for *.jsf?

Thanks in advance,

Seb
[ July 27, 2005: Message edited by: seb petterson ]



Hi Ranchers,

I am facing the similar problem. Actually I need to configure a JSF application on eclipse Ide using Websphere CE server. This application currently working on Netbeans Ide and uses Sun One Server. I tried to configure on eclipse using Tomcat first and have tried to run a jsp. I got "404 page not found error" as mentioned in quoted message and the extension changed to jsf. I am new to Websphere and have no idea, how to go about. Could you please let me know the steps involved or probably the helpful links to get my work done.

Thanks & Regards
10 years ago
JSF
hi Great Ranchers,

I've a problem with HTML forms in my jsp. Actually I have a form, when I submit the for it dose perform some logic that's fine. But the problem is when I refresh the web page (by pressing refresh button of browser), it performs the same logic again which isn't desirable.

Kindly tell me the proper solution ASAP.

Thanks & Regards
10 years ago
JSP
Hi Renchers,

I have a pop up on which some masseges are given. The problem is I am unable to select any text through mouse so that I can copy it to use further. But for the the same popup, I am able to select the text in Mozilla Firefox. Kindly tell me any solution to this. It's urgent ....

Thanks & Regards
Hi Friends,

Could you please let me know that where I can find "Struts 2 Design and Programming" by Budi Kurniawan in India. Is't available in Mumbai at any book store ...

Thanks & Regards
10 years ago
Hi Preeti,

Please check your private message ...

Thanks & Regards
10 years ago
public class StringTest {
public static void main(String[] args) {
String s1 = "abc";
String s2 = "ab";
s2 = s2 + "c";
System.out.println(s1 == s2); // false
System.out.println(s1 == (s2.intern())); // true
}
}

Hi Great Ranchers ... I am a bit confused ... .... ..... Please explain the above output ....

Thanks Regards
Hi Preeti,

Thanks For Your Valuable suggestion ....
10 years ago