Hello i have created a simple GWT application which allows user to
add Name,address,email,sex and phone number.
E.G On UI there is 4 text boxes for Name,address,phone,email and
select box for sex
I have implemented hibernate and hsqldb, but when i am running the
program it gives me the following error.
[TRACE] [gwt_hibernate] - Finding entry point classes
[ERROR] [gwt_hibernate] - Errors in 'file:/I:/PROJECTS/gwt_hibernate/
src/gwt_hibernate/client/Gwt_hibernate.java'
[ERROR] [gwt_hibernate] - Line 39: The import
org.hibernate.HibernateException cannot be resolved
[ERROR] [gwt_hibernate] - Line 40: The import org.hibernate.Session
cannot be resolved
[ERROR] [gwt_hibernate] - Line 41: The import
org.hibernate.SessionFactory cannot be resolved
[ERROR] [gwt_hibernate] - Line 42: The import
org.hibernate.Transaction cannot be resolved
[ERROR] [gwt_hibernate] - Line 43: The import org.hibernate.cfg
cannot be resolved
[ERROR] [gwt_hibernate] - Line 164: SessionFactory cannot be
resolved to a type
[ERROR] [gwt_hibernate] - Line 166: Configuration cannot be resolved
to a type
[ERROR] [gwt_hibernate] - Line 168: Session cannot be resolved to a
type
[ERROR] [gwt_hibernate] - Line 191: HibernateException cannot be
resolved to a type
[ERROR] [gwt_hibernate] - Unable to find type
'gwt_hibernate.client.Gwt_hibernate'
[ERROR] [gwt_hibernate] - Hint: Previous compiler errors may have
made this type unavailable
[ERROR] [gwt_hibernate] - Hint: Check the inheritance chain from
your module; it may not be inheriting a required module or a module
may not be adding its source path entries properly
[ERROR] [gwt_hibernate] - Failed to load module 'gwt_hibernate' from
user agent 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.19 (KHTML,
like Gecko) Chrome/18.0.1025.162 Safari/535.19' at activate.adobe.com:
60298
I have created one hibernate.cfg.xml file, one persistent class and
other xml file.
Here is the code i did.
Persistent Class: cls_tbl_user
package gwt_hibernate.client;
public class cls_tbl_user
{
private String id;
private String name;
private String address;
private String email;
private String phone;
private String sex;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property
name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:file:i:/HSQLDB/
test1db</property>
<property name="connection.username">SA</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</
property>
<!-- Enable Hibernate's automatic session context management --
>
<property name="current_session_context_class">thread</
property>
<!-- Disable the second-level cache -->
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</
property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup
<property name="hbm2ddl.update">create</property>-->
<mapping resource="gwt_hibernate.client.cls_tbl_user.hbm.xml"/
>
</session-factory>
</hibernate-configuration>
cls_tbl_user.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="gwt_hibernate.client.cls_tbl_user"
table="sc_user.tbl_user">
<id name="id" type="string" column="user_id" />
<property name="name" type="string" column="name"/>
<property name="email" type="string" column="email"/>
<property name="address" type="string" column="address"/>
<property name="phone" type="string" column="phone" />
</class>
</hibernate-mapping>
and following is the entrypoint class
Gwt_hibernate.java
public class Gwt_hibernate implements EntryPoint {
/**
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final FormPanel form_panel = new FormPanel();
form_panel.setAction("/my_from_handler");
form_panel.setEncoding(FormPanel.ENCODING_MULTIPART);
form_panel.setMethod(FormPanel.METHOD_POST);
VerticalPanel vertical_panel = new VerticalPanel();
HorizontalPanel hori_panel = new HorizontalPanel();
form_panel.setWidget(hori_panel);
DatePicker datePicker = new DatePicker();
final Label text = new Label();
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
// TODO Auto-generated method stub
Date date = event.getValue();
String date_string =
DateTimeFormat.getMediumDateFormat().format(date);
text.setText(date_string);
}
});
//datePicker.setValue(new Date(),true);
//hori_panel.add(text);
//hori_panel.add(datePicker);
final TextBox txt_name = new TextBox();
txt_name.setName("txt_name");
Label lbl_name = new Label("Name:");
final TextBox txt_address = new TextBox();
txt_address.setName("txt_address");
Label lbl_address = new Label("Address:");
final TextBox txt_phone = new TextBox();
txt_phone.setName("txt_phone");
Label lbl_phone = new Label("Phone:");
final TextBox txt_email = new TextBox();
txt_email.setName("txt_email");
Label lbl_email = new Label("Email:");
HorizontalPanel hori_2 = new HorizontalPanel();
hori_2.add(lbl_name);
hori_2.add(txt_name);
HorizontalPanel hori_3 = new HorizontalPanel();
hori_3.add(lbl_address);
hori_3.add(txt_address);
HorizontalPanel hori_4 = new HorizontalPanel();
hori_4.add(lbl_email);
hori_4.add(txt_email);
final ListBox lst_sex = new ListBox();
Label lbl_sex = new Label("Sex:");
lst_sex.setName("lst_sex");
lst_sex.addItem("Male", "0");
lst_sex.addItem("Female", "1");
HorizontalPanel hori_5 = new HorizontalPanel();
hori_5.add(lbl_sex);
hori_5.add(lst_sex);
HorizontalPanel hori_6 = new HorizontalPanel();
hori_6.add(new Button("Submit",new ClickListener() {
@Override
public void onClick(Widget sender) {
form_panel.submit();
}
}));
//remote method to call
final String method= "trasfer_data";
//parameter holder
final Map params = new HashMap();
form_panel.addFormHandler(new FormHandler() {
@Override
public void onSubmitComplete(FormSubmitCompleteEvent event) {
// TODO Auto-generated method stub
}
@Override
public void onSubmit(FormSubmitEvent event) {
// TODO Auto-generated method stub
if(txt_name.getText().length()==0)
{
Window.alert("Please enter the data in textbox");
event.setCancelled(true);
}
else
{
SessionFactory sessionFactory = new
Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
Session session =sessionFactory.openSession();
try
{
System.out.println("Inserting Records");
cls_tbl_user obj_cls_data = new cls_tbl_user();
obj_cls_data.setId("1");
obj_cls_data.setName("rahul");
obj_cls_data.setAddress("ahmedabad");
obj_cls_data.setEmail("rahul.gamit89@gmail.com");
obj_cls_data.setSex("male");
obj_cls_data.setPhone("9727257008");
session.save(obj_cls_data);
System.out.println("Record Inserted Successfully..");
}
catch(HibernateException e)
{
System.out.println(e.getMessage());
} finally
{
session.flush();
session.close();
}
}
}
});
vertical_panel.add(form_panel);
vertical_panel.add(hori_panel);
vertical_panel.add(hori_2);
vertical_panel.add(hori_3);
vertical_panel.add(hori_4);
vertical_panel.add(hori_5);
vertical_panel.add(hori_6);
RootPanel.get().add(vertical_panel);
}
}
following is the error i am facing even though i have imported the
org.HibernateException.
The import org.hibernate.HibernateException cannot be resolved
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment