nisu pathak

Greenhorn
+ Follow
since Nov 03, 2013
Merit badge: grant badges
For More
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 nisu pathak



i am posting sample code :please help me in relationship
package org.optical.entity;

i









applicationcontext.xml
package org.optical.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="supplier_product_category")
public class Supplier_product_category implements Serializable
{

/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="SUPPLIER_ID")
private Integer SUPPLIER_ID;
@Column(name="CATEGORY_ID")
private Integer CATEGORY_ID;
@Column(name="STATUS")
private String STATUS;
@Column(name="DESCRIPTION")
private String DESCRIPTION;

private Product_category category;

private Supplier_master master;

public Integer getSUPPLIER_ID() {
return SUPPLIER_ID;
}
public void setSUPPLIER_ID(Integer sUPPLIER_ID) {
SUPPLIER_ID = sUPPLIER_ID;
}

@ManyToOne(targetEntity=Supplier_master.class)
@JoinColumn(name="SUPPLIER_ID", insertable=true, updatable=false)
public Supplier_master getMaster() {
return master;
}
public void setMaster(Supplier_master master) {
this.master = master;
}


public Integer getCATEGORY_ID() {
return CATEGORY_ID;
}
public void setCATEGORY_ID(Integer cATEGORY_ID) {
CATEGORY_ID = cATEGORY_ID;
}

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name="CATEGORY_ID",referencedColumnName="CATEGORY_ID",insertable=true,updatable=false)
public Product_category getCategory() {
return category;
}
public void setCategory(Product_category category) {
this.category = category;
}

public String getSTATUS() {
return STATUS;
}
public void setSTATUS(String sTATUS) {
STATUS = sTATUS;
}
public String getDESCRIPTION() {
return DESCRIPTION;
}
public void setDESCRIPTION(String dESCRIPTION) {
DESCRIPTION = dESCRIPTION;
}




}

TestConfig.java to test configuration


please help me i m in hurry ...
i am getting following error


log4j:WARN No appenders could be found for logger (org.springframework.core.io.support.PathMatchingResourcePatternResolver).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationcontext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.List, at table: supplier_master, for columns: [org.hibernate.mapping.Column(category)]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at org.TestConfig.main(TestConfig.java:19)
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: supplier_master, for columns: [org.hibernate.mapping.Column(category)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.Property.isValid(Property.java:207)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 12 more



Hello ,i am implementing code of edit/update row of datatable in jsf .i am posting code .please help me as early as possible due to dead lines

package org.demo;

import java.util.ArrayList;
import java.util.Arrays;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="order")
@SessionScoped

public class OrderBean
{
private int pid;
private String name;
private int price;
boolean editable;

public OrderBean() { }
public OrderBean(int pid,String name,int price)
{
this.pid=pid;
this.name=name;
this.price=price;


}


public boolean isEditable() {
return editable;
}
public void setEditable(boolean editable) {
this.editable = editable;
}

public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}







private static final ArrayList<OrderBean> orderList =new ArrayList<OrderBean>(Arrays.asList(

new OrderBean(101,"Rice",1100),
new OrderBean(102,"oil",1400),
new OrderBean(103,"a",1000),
new OrderBean(104,"b",600),
new OrderBean(105,"c",700)
));

public ArrayList<OrderBean> getOrderList() {

return orderList;

}

public String addAction()
{

OrderBean order = new OrderBean(this.pid, this.name,
this.price);

orderList.add(order);

return null;


}

public String saveAction() {

//get all existing value but set "editable" to false
for (OrderBean order : orderList){
order.setEditable(false);
}
//return to current page
return null;

}
public String deleteAction(OrderBean order) {

orderList.remove(order);
return null;
}

public String editAction(OrderBean order)
{

//order.setEditable(true);
order.setEditable(true);

return null;
}


}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/WEB-INF/templates/template.xhtml">
<ui:param name="title" value="Applicant System" />

<ui:define name="header">
<h:graphicImage library="images" name="icefaces.png"/>
</ui:define>

<ui:define name="menu">
<h:button outcome="applicants" value="Listing Page" />
</ui:define>

<ui:define name="content">
<h:head>
<h:outputStylesheet library="css" name="template.css" />


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">



$(document).ready(function()
{
$('#output').click(function(event) {

alert("inside jquery");
$.ajax({
url: "data.jsf",
type: "POST",
data:{pid:$('#pid'),name:$('#name'),price:$('#price')},
dataType: "json",
success : function(data)
{
alert("inside success");
}
});
};

});
});

</script>


</h:head>
<h:form id="f1" prependId="false">
<h:messages globalOnly="true" />
<h:panelGroup id="table" layout="block" >
<table>


<tr>
<td>
<h:outputLabel value="Product id :"></h:outputLabel>
</td>

<td>
<h:inputText id="pid"
value="#{order.pid}"
required="true" >

</h:inputText>
</td>

</tr>

<tr>
<td>
<h:outputLabel value="Product Name:"></h:outputLabel>
</td>
<td>
<h:inputText id="name"
value="#{order.name}"
required="true" >

</h:inputText>
</td>

</tr>

<tr>
<td>
<h:outputLabel value="Product Price:"></h:outputLabel>
</td>

<td>
<h:inputText id="price"
value="#{order.price}"
required="true" >

</h:inputText>
</td>

</tr>
<tr>
<td>

<h:commandButton id="output" value="Add" action="#{order.addAction}"/>

</td>


</tr>
</table>



</h:panelGroup>

<h:dataTable value="#{order.orderList}" var="o"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row" border="2">

<h:column>

<f:facet name="header">Order No</f:facet>

<h:inputText value="#{o.pid}" size="10" rendered="#{o.editable}" />

<h:outputText value="#{o.pid}" rendered="#{not o.editable}" />

</h:column>

<h:column>

<f:facet name="header">Product Name</f:facet>

<h:inputText value="#{o.name}" size="20" rendered="#{o.editable}" />

<h:outputText value="#{o.name}" rendered="#{not o.editable}" />

</h:column>

<h:column>

<f:facet name="header">Price</f:facet>

<h:inputText value="#{o.price}" size="10" rendered="#{o.editable}" />

<h:outputText value="#{o.price}" rendered="#{not o.editable}" />

</h:column>


<h:column>
<f:facet name="header">Action</f:facet>

<h:commandLink value="Edit" action="#{order.editAction(o)}"
rendered="#{not o.editable}" />


</h:column>

<h:column>

<f:facet name="header">Action</f:facet>

<h:commandLink value="Delete"
action="#{order.deleteAction(o)}" /> //Error on this line
Method must have signature "String method(), String method(), String method(String), String method(String,
String), String method(String, String, String), String method(String, String, String, String), String method(String,
String, String, String, String), String method(String, String, String, String, String, String), String method(String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String), String method(String, String, String, String, String, String, String, String, String), String method(String,
String, String, String, String, String, String, String, String, String), String method(String, String, String, String,
String, String, String, String, String, String, String), String method(String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String, String), String method(String, String, String, String, String, String,
String, String, String, String, String, String, String, String, String), String method(String, String, String, String,
String, String, String, String, String, String, String, String, String, String, String, String), String method(String,
String, String, String, String, String, String, String, String, String, String, String, String, String, String, String,
String), String method(String, String, String, String, String, String, String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String, String, String, String, String, String, String)" but has signature "String
method(OrderBean)"

</h:column>


</h:dataTable>

<h:commandButton value="Save Changes" action="#{order.saveAction}" />

</h:form>
</ui:define>

</ui:composition>
</html>

10 years ago
JSF
Actually i have added all jars by building class path .eclipse provides this option in order to add librarby thats what is called UserLibrary.is it compulsary to add all jars into lib folder ?thats what i am asking?
10 years ago
i have included all jars associated with spring core and spring mvc into as a userlibrary.
is it ok or should i add all jars to WEB-INF/lib folder?
yes ,i do have that jar and still i am getting same error.any other answer?
10 years ago
Hello friends i am working on spring mvc.i have included all jars related to spring core and spring mvc ..when i am running my web application i am getting following error:

cannot Deploy MyFinalprj
deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet. Please see server.log for more details.

Can any one help me out what was the issue?

Thanks in advance
10 years ago
hello hope all you are fine .i need code which allows to integrate spring mvc with jsf .can any one help me ?
persistance.xml is required if i am integrating JPA with Spring mvc?

can anyone provide me detail code with explanation ?

Thanks In Advance


hello friends hope all you are fine.

i am confuse that for web application is it necessary to use maven ? if i am adding all jars that required to develop web application .that scenerio is not good? i didnt get why to use Maven? please help me and also help me for spring jsf jpa integration

i want to integrate spring jsf and jpa.

index.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">

<h:head>
<title> Spring jsf jpa integration </title>
</h:head>

<h:body>

<h:outputText id="id" value="ID : "/>
<h:message for="txtid"/>
<h:inputText id="txtID" value="#{UserBeanManager.id}"/>

<h:outputText id="txtNAME" value="Name:"/>
<h:inputText id="txtName" value="#{UserBeanManager.name}"/>
<h:outputText id="txtPASSWORD" value="password:"/>
<h:inputText id="txtName" value="#{UserBeanManage.password}"/>

<h:commandButton value="#{UserBeanManager.adduser}"></h:commandButton>
</h:body>



</html>



Model class :


Dao Layer




Dao implementation




//Service Layer


//Service Layer implementation
package org.integration.service;






Please help me

thanks
hello.i am trying to is integrate jpa into my servlets .i am posting my code as below:



i am getting following error
javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [org.apache.derby.jdbc.ClientDriver], user [] and URL [jdbc:derby:localhost:1527/sample;create=true]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:derby:localhost:1527/sample;create=true
Error Code: 0

please need to ocmplete as early as possible .early suggestions are most welcomed..

Thanks in advance.


//suppose i am defining container managed Datasource into glashfish server.is it possible to inject that Resource into java application ?
if yes can anyone provide me code snippet of it?


Thanks in advance
hello friends i want to implement hibenate managed connection pooling usign C3P0.i can't be able to establish connection to derby database.i am pasting my code here :

i simply want to persist Employee Data







at ij client i am executing this command : connect jdbc:derby:MyDb is it appropriate .here i am not defining port(1527) as per Derby Documentation it is correct ?
i am getting following error:
log4j:WARN No appenders could be found for logger (org.hibernate.type.BasicTypeRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
at org.Model.Client.main(Client.java:31)
Caused by: java.sql.SQLException: Database 'myDb' not found.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.Driver20.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:190)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 5 more
Caused by: java.sql.SQLException: Database 'myDb' not found.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 21 more
hey Differance exist for only select statement.to execute other dml statements syntax remains the same both for Jpql and HQL.
Hello i have configured JNDI.i have configured java Mail session into glashfish server named mail/MyMailConfig.the code for sending mail using jndi is given below :





though i am getting following error even if i have configured Mail Session Properly ::

Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.main.Main.runTest(Main.java:22)
at org.main.Main.main(Main.java:58)

please help me i am stuck with it..
thanks
Npp90
i have not explicitely defined entry type.but key or entry can be anything .in this case entry should be of type String .even if i type case entry into String it doesn't work .so how it can be possible ?
10 years ago
i am getting ClassCastException even if i am explicitely casting custom object into string ..i want to know the reason why it is happening.
//any implementation of map will throw null pointer exception
import java.util.*;

class student
{
private String id;
public student(){}
public student(String id) {this.id=id;}
}

public class HashTableExample
{
public static void main(String args[])
{
Hashtable h = new Hashtable();

h.put("A","Apple");
h.put(new StringBuffer("p").toString(),"nitesh");
h.put(new student("p").toString(),"naresh");
Set<String> s=h.entrySet();

for(String str:s)
{
String s1=(String)h.get(s);

System.out.println(s1);
}


}
}

give me some suggestions
Thanks
10 years ago