w tym temacie robiłem dodanie z klasy: http://4programmers.net/Forum/559917#id559917
teraz próbuje z poziomu JSP zrobić to samo, na Tomcat 5.5, ale wali mi błąd, że nie może znaleźć klasy testbaza: org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 14 in the jsp file: /index.jsp
testbaza cannot be resolved to a type
11: Session session1 = factory.openSession();
12: session1.beginTransaction();
13:
14: testbaza baza = new testbaza("ania");
15: session1.save(baza);
16: session1.getTransaction().commit();
17: session1.close();
wklejam kody, pomóżcie please
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "testbaza")
public class testbaza {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Basic(optional = false)
@Column(name = "name", unique = false, nullable = false)
private String name;
public testbaza (String name){
this.name = name;
}
public testbaza(){
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" import="org.hibernate.*,org.hibernate.cfg.*" pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>test hibernate</TITLE>
</HEAD>
<BODY>
<%
SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session1 = factory.openSession();
session1.beginTransaction();
testbaza baza = new testbaza("ania");
session1.save(baza);
session1.getTransaction().commit();
session1.close();
%>
</BODY>
</html>