Skip to content

Commit 6fcf951

Browse files
committed
Commit inicial
0 parents  commit 6fcf951

30 files changed

+2220
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# JavaHibernateExemplo
2+
3+
Projeto simples desenvolvido no NetBeans utilizando a linguagem Java fazendo integração com o banco de dados MySQL para demonstrar o uso do Framework Hibernate.
4+
5+
As operações exemplificadas nesse projeto são as de: inserção, leitura, alteração e remoção (CRUD) de contatos no banco de dados MySQL.
6+
7+
* Downloads: https://github.com/iagocolodetti/JavaHibernateExemplo/releases
8+
* [Arquivo de Script MySQL](https://github.com/iagocolodetti/JavaHibernateExemplo/releases/download/v1.0/contatodb.sql "contatodb.sql")
9+
* [Bibliotecas Necessárias](https://github.com/iagocolodetti/JavaHibernateExemplo/releases/download/v1.0/bibliotecas.zip "bibliotecas.zip")
10+
* [Código-Fonte](https://github.com/iagocolodetti/JavaHibernateExemplo/archive/v1.0.zip "v1.0.zip")
11+
12+
13+
14+
# Adicionando arquivos necessários para usar o Hibernate
15+
16+
* Novo -> Outros -> Hibernate
17+
* Adicionar: "Assistente de Configuração do Hibernate"
18+
* Adicionar: "HibernateUtil.java"
19+
20+
21+
# Configurando o "hibernate.cfg.xml" usando a aba "Design"
22+
* Propriedades de JDBC
23+
* "hibernate.connection.driver_class" usar valor correspondente ao driver de conexão, aqui: com.mysql.jdbc.Driver
24+
* "hibernate.connection.url" usar como valor a url de acesso ao banco, aqui: jdbc:mysql://localhost:3306/contatodb
25+
* "hibernate.connection.username" usar como valor seu nome de usuário para acesso ao banco.
26+
* "hibernate.connection.password" usar como valor sua senha para acesso ao banco.
27+
28+
* Mapeamento: Adicionar a classe Entidade, aqui: Contato
29+
30+
* Propriedades Diversas: Adicionar a propriedade "hibernate.hbm2ddl.auto" valor "update"
31+
32+
33+
**Código-fonte do arquivo:**
34+
```<?xml version="1.0" encoding="UTF-8"?>
35+
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
36+
<hibernate-configuration>
37+
<session-factory>
38+
<property name="hibernate.hbm2ddl.auto">update</property>
39+
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
40+
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/contatodb</property>
41+
<property name="hibernate.connection.username">root</property>
42+
<property name="hibernate.connection.password">root</property>
43+
<mapping class="Contato"/>
44+
</session-factory>
45+
</hibernate-configuration>
46+
```

build.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project name="JavaHibernateExemplo" default="default" basedir=".">
11+
<description>Builds, tests, and runs the project JavaHibernateExemplo.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-jar: called before JAR building
30+
-post-jar: called after JAR building
31+
-post-clean: called after cleaning build products
32+
33+
(Targets beginning with '-' are not intended to be called on their own.)
34+
35+
Example of inserting an obfuscator after compilation could look like this:
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Another way to customize the build is by overriding existing main targets.
48+
The targets of interest are:
49+
50+
-init-macrodef-javac: defines macro for javac compilation
51+
-init-macrodef-junit: defines macro for junit execution
52+
-init-macrodef-debug: defines macro for class debugging
53+
-init-macrodef-java: defines macro for class execution
54+
-do-jar: JAR building
55+
run: execution of project
56+
-javadoc-build: Javadoc generation
57+
test-report: JUnit report generation
58+
59+
An example of overriding the target for project execution could look like this:
60+
61+
<target name="run" depends="JavaHibernateExemplo-impl.jar">
62+
<exec dir="bin" executable="launcher.exe">
63+
<arg file="${dist.jar}"/>
64+
</exec>
65+
</target>
66+
67+
Notice that the overridden target depends on the jar target and not only on
68+
the compile target as the regular run target does. Again, for a list of available
69+
properties which you can use, check the target you are overriding in the
70+
nbproject/build-impl.xml file.
71+
72+
-->
73+
</project>

lib/antlr-2.7.7.jar

427 KB
Binary file not shown.

lib/c3p0-0.9.2.1.jar

413 KB
Binary file not shown.

lib/dom4j-1.6.1.jar

303 KB
Binary file not shown.

lib/ehcache-core-2.4.3.jar

984 KB
Binary file not shown.

lib/hibernate-c3p0-4.3.1.Final.jar

38.2 KB
Binary file not shown.
74 KB
Binary file not shown.

lib/hibernate-core-4.3.1.Final.jar

4.95 MB
Binary file not shown.
131 KB
Binary file not shown.

0 commit comments

Comments
 (0)