{"id":20504887,"url":"https://github.com/nfriaa/hibernate-tutorial2","last_synced_at":"2026-05-07T09:34:09.133Z","repository":{"id":201889818,"uuid":"105526049","full_name":"nfriaa/hibernate-tutorial2","owner":"nfriaa","description":"Hibernate tutorial 2 : XML Mapping","archived":false,"fork":false,"pushed_at":"2017-10-18T17:37:58.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-26T05:47:13.410Z","etag":null,"topics":["hibernate","hibernate5","java","maven","mysql","xml-mapping"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfriaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-10-02T11:16:26.000Z","updated_at":"2017-10-09T15:15:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4fc48be-4701-406d-9bd3-e6512ae3cafd","html_url":"https://github.com/nfriaa/hibernate-tutorial2","commit_stats":null,"previous_names":["nfriaa/hibernate-tutorial2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nfriaa/hibernate-tutorial2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriaa%2Fhibernate-tutorial2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriaa%2Fhibernate-tutorial2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriaa%2Fhibernate-tutorial2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriaa%2Fhibernate-tutorial2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfriaa","download_url":"https://codeload.github.com/nfriaa/hibernate-tutorial2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriaa%2Fhibernate-tutorial2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32731577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hibernate","hibernate5","java","maven","mysql","xml-mapping"],"created_at":"2024-11-15T19:41:03.095Z","updated_at":"2026-05-07T09:34:09.098Z","avatar_url":"https://github.com/nfriaa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hibernate-tutorial2\nHibernate XML Mapping files *(Obsolete !!! We will see in Tutorial 3 the mode \"Hibernate Annotations\")*\n\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg?style=flat)](https://github.com/nfriaa/hibernate-tutorial2/issues) [![Travis](https://img.shields.io/travis/rust-lang/rust.svg)](https://github.com/nfriaa/hibernate-tutorial2) [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/nfriaa/hibernate-tutorial2/blob/master/LICENSE)\n\n## Description\nA sample code to execute Queries under Hibernate ORM (not directly to sql)\n* JavaSE 8\n* Hibernate 5\n* Maven 4\n* MySQL 5\n\n## 1. Database and tables\nWe will use the same database and table structure in Tutorial 1\n\n## 2. Create maven project and add dependencies\n```xml\n\u003c!-- MySQL connector --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003emysql\u003c/groupId\u003e\n    \u003cartifactId\u003emysql-connector-java\u003c/artifactId\u003e\n    \u003cversion\u003e6.0.6\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003c!-- Hibernate --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.hibernate\u003c/groupId\u003e\n    \u003cartifactId\u003ehibernate-core\u003c/artifactId\u003e\n    \u003cversion\u003e5.2.11.Final\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 3. Create POJO (Plain Old Java Object) class\n```java\npublic class Product\n{\n    private int id;\n    private String name;\n    private int price;\n\n    // getters and setters here...\n}\n```\n## 4. Create the XML mapping file\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE hibernate-mapping PUBLIC \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n\"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\"\u003e\n\n\u003chibernate-mapping\u003e\n    \u003cclass name=\"net.isetjb.hibernatetutorial2.Product\" table=\"product\"\u003e\n        \u003cmeta attribute=\"class-description\"\u003e\n            Add your class description here.\n        \u003c/meta\u003e\n        \u003cid name=\"id\" type=\"int\" column=\"id\"\u003e\n            \u003cgenerator class=\"native\"/\u003e\n        \u003c/id\u003e\n        \u003cproperty name=\"name\" type=\"string\"\u003e\n            \u003ccolumn name=\"name\" length=\"255\" not-null=\"true\"/\u003e\n        \u003c/property\u003e\n        \u003cproperty name=\"price\" type=\"int\"\u003e\n            \u003ccolumn name=\"price\" not-null=\"true\"/\u003e\n        \u003c/property\u003e\n    \u003c/class\u003e\n\u003c/hibernate-mapping\u003e\n```\n\n## 5. Create the hibernate config file 'hibernate.cfg.xml' (in ressources folder)\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE hibernate-configuration PUBLIC \"-//Hibernate/Hibernate Configuration DTD 3.0//EN\" \"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\"\u003e\n\n\u003chibernate-configuration\u003e\n    \u003csession-factory\u003e\n        \u003cproperty name=\"hibernate.dialect\"\u003eorg.hibernate.dialect.MySQLDialect\u003c/property\u003e\n        \u003cproperty name=\"hibernate.connection.url\"\u003ejdbc:mysql://localhost:3306/persist_db?useTimezone=true\u0026amp;serverTimezone=UTC\u003c/property\u003e\n        \u003cproperty name=\"hibernate.connection.username\"\u003eroot\u003c/property\u003e\n        \u003cproperty name=\"hibernate.connection.password\"\u003e\u003c/property\u003e\n        \u003cproperty name=\"show_sql\"\u003etrue\u003c/property\u003e\n        \u003cmapping file=\"src/main/java/net/isetjb/hibernatetutorial2/Product.hbm.xml\"/\u003e\n    \u003c/session-factory\u003e\n\u003c/hibernate-configuration\u003e\n```\n\n## 6. Create HibernateUtil.java \nHibernate Utility class with a convenient method to get Session Factory.\n\n## 7. Create main Application class\n* a class whith main method to test connection\n* implement CRUD operations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfriaa%2Fhibernate-tutorial2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfriaa%2Fhibernate-tutorial2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfriaa%2Fhibernate-tutorial2/lists"}