use of ru.ivmiit.models.User in project JAVA_FIX by MarselSidikov.
the class Application method main.
public static void main(String[] args) {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.connection.url", "jdbc:postgresql://localhost:5432/postgres");
configuration.setProperty("hibernate.connection.username", "postgres");
configuration.setProperty("hibernate.connection.password", "qwerty007");
configuration.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQL95Dialect");
configuration.setProperty("hibernate.hbm2ddl.auto", "update");
configuration.addResource("User.hbm.xml");
configuration.addAnnotatedClass(Car.class);
configuration.setProperty("hibernate.show_sql", "true");
SessionFactory sessionFactory = configuration.buildSessionFactory();
Session session = sessionFactory.openSession();
User user = session.createQuery("from User user where user.id = 1", User.class).getSingleResult();
session.beginTransaction();
session.save(new User("Mini", "Max", 99));
session.getTransaction().commit();
System.out.println(user);
List<Car> car = session.createQuery("from Car car", Car.class).getResultList();
int i = 0;
}
use of ru.ivmiit.models.User in project JAVA_FIX by MarselSidikov.
the class SignUpServlet method doPost.
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// вытащили данные регистрации
String name = req.getParameter("name");
String password = req.getParameter("password");
LocalDate birthDate = LocalDate.parse(req.getParameter("birthDate"));
// создали пользователя и сохранили его в хранилище
User user = new User(name, password, birthDate);
usersRepository.save(user);
doGet(req, resp);
}
use of ru.ivmiit.models.User in project JAVA_FIX by MarselSidikov.
the class SignUpServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
List<User> users = usersRepository.findAll();
req.setAttribute("usersFromServer", users);
RequestDispatcher dispatcher = req.getServletContext().getRequestDispatcher("/jsp/signUp.jsp");
dispatcher.forward(req, resp);
}
Aggregations