connected to the data base and created models
This commit is contained in:
commit
7f2c44cd59
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
42
pom.xml
Normal file
42
pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>PRA2024</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>18</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.orm</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>6.4.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
40
src/main/java/org/example/FilmCategoryModel.java
Normal file
40
src/main/java/org/example/FilmCategoryModel.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name="category")
|
||||
public class FilmCategoryModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="film_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="title")
|
||||
private String filmCategory;
|
||||
|
||||
public FilmCategoryModel() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilmCategory() {
|
||||
return filmCategory;
|
||||
}
|
||||
|
||||
public void setFilmCategory(String filmCategory) {
|
||||
this.filmCategory = filmCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Category{" +
|
||||
"id=" + id +
|
||||
", filmCategory='" + filmCategory + '}';
|
||||
}
|
||||
}
|
98
src/main/java/org/example/FilmInfoModel.java
Normal file
98
src/main/java/org/example/FilmInfoModel.java
Normal file
@ -0,0 +1,98 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name="films_info")
|
||||
public class FilmInfoModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="film_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="description")
|
||||
private String filmDescription;
|
||||
|
||||
@Column(name="release_year")
|
||||
private int releaseYear;
|
||||
|
||||
@Column(name="language_id")
|
||||
private int filmLanguage;
|
||||
|
||||
@Column(name="length")
|
||||
private int filmLength;
|
||||
|
||||
@Column(name="rating")
|
||||
private String filmRating;
|
||||
|
||||
@Column(name="category_id")
|
||||
private int filmCategory;
|
||||
|
||||
public FilmInfoModel() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilmDescription() {
|
||||
return filmDescription;
|
||||
}
|
||||
|
||||
public void setFilmDescription(String filmDescription) {
|
||||
this.filmDescription = filmDescription;
|
||||
}
|
||||
|
||||
public int getReleaseYear() {
|
||||
return releaseYear;
|
||||
}
|
||||
|
||||
public void setReleaseYear(int releaseYear) {
|
||||
this.releaseYear = releaseYear;
|
||||
}
|
||||
|
||||
public int getFilmLanguage() {
|
||||
return filmLanguage;
|
||||
}
|
||||
|
||||
public void setFilmLanguage(int filmLanguage) {
|
||||
this.filmLanguage = filmLanguage;
|
||||
}
|
||||
|
||||
public int getFilmLength() {
|
||||
return filmLength;
|
||||
}
|
||||
|
||||
public void setFilmLength(int filmLength) {
|
||||
this.filmLength = filmLength;
|
||||
}
|
||||
|
||||
public String getFilmRating() {
|
||||
return filmRating;
|
||||
}
|
||||
|
||||
public void setFilmRating(String filmRating) {
|
||||
this.filmRating = filmRating;
|
||||
}
|
||||
|
||||
public int getFilmCategory() {
|
||||
return filmCategory;
|
||||
}
|
||||
|
||||
public void setFilmCategory(int filmCategory) {
|
||||
this.filmCategory = filmCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilmInfo{" +
|
||||
"id=" + id +
|
||||
", filmDescription=" + filmDescription + '\n' +
|
||||
", releaseYear=" + releaseYear + ", filmLanguage=" + filmLanguage + '\n' +
|
||||
", filmLength=" + filmLength + ", filmRating=" + filmRating + '\n' +
|
||||
", filmCategory=" + filmCategory + '}';
|
||||
}
|
||||
}
|
40
src/main/java/org/example/FilmLanguageModel.java
Normal file
40
src/main/java/org/example/FilmLanguageModel.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name="language")
|
||||
public class FilmLanguageModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="language_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="language")
|
||||
private String filmLanguage;
|
||||
|
||||
public FilmLanguageModel() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilmLanguage() {
|
||||
return filmLanguage;
|
||||
}
|
||||
|
||||
public void setFilmLanguage(String filmLanguage) {
|
||||
this.filmLanguage = filmLanguage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Language{" +
|
||||
"id=" + id +
|
||||
", filmLanguage='" + filmLanguage + '}';
|
||||
}
|
||||
}
|
40
src/main/java/org/example/FilmModel.java
Normal file
40
src/main/java/org/example/FilmModel.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.example;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name="films")
|
||||
public class FilmModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="film_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="title")
|
||||
private String filmTitle;
|
||||
|
||||
public FilmModel() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilmTitle() {
|
||||
return filmTitle;
|
||||
}
|
||||
|
||||
public void setFilmTitle(String filmTitle) {
|
||||
this.filmTitle = filmTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Film{" +
|
||||
"id=" + id +
|
||||
", filmTitle='" + filmTitle + '}';
|
||||
}
|
||||
}
|
51
src/main/java/org/example/Main.java
Normal file
51
src/main/java/org/example/Main.java
Normal file
@ -0,0 +1,51 @@
|
||||
//package org.example;
|
||||
//
|
||||
//public class Main {
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println("Hello world!");
|
||||
// }
|
||||
//}
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Start");
|
||||
|
||||
// Tworzenie obiektu konfiguracji Hibernate
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.configure(); // Domyślnie wczytuje plik hibernate.cfg.xml
|
||||
|
||||
// Tworzenie obiektu sesji
|
||||
try (SessionFactory sessionFactory = configuration.buildSessionFactory()) {
|
||||
// Otwieranie sesji
|
||||
try (Session session = sessionFactory.openSession()) {
|
||||
// Rozpoczęcie transakcji
|
||||
session.beginTransaction();
|
||||
|
||||
// Wykonanie zapytania SQL
|
||||
List<Object[]> result = session.createQuery("SELECT * FROM film").list();
|
||||
|
||||
// Wypisywanie wyników na konsoli
|
||||
for (Object[] row : result) {
|
||||
for (Object column : row) {
|
||||
System.out.print(column + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
// Zakończenie transakcji
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Done");
|
||||
}
|
||||
}
|
21
src/main/resources/hibernate.cfg.xml
Normal file
21
src/main/resources/hibernate.cfg.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<!-- ustawienia połączenia z bazą danych -->
|
||||
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
|
||||
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/PRA2024</property>
|
||||
<property name="hibernate.connection.username">postgres</property>
|
||||
<property name="hibernate.connection.password">password</property>
|
||||
|
||||
<!-- inne ustawienia Hibernate -->
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
|
||||
<property name="hibernate.show_sql">true</property>
|
||||
<property name="hibernate.hbm2ddl.auto">update</property>
|
||||
|
||||
<!-- skanowanie pakietów z encjami -->
|
||||
<mapping class="org.example.FilmModel"/>
|
||||
<mapping class="org.example.FilmInfoModel"/>
|
||||
<mapping class="org.example.FilmLanguageModel"/>
|
||||
<mapping class="org.example.FilmCategoryModel"/>
|
||||
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
68
src/test/java/org/example/HibernateExampleTest.java
Normal file
68
src/test/java/org/example/HibernateExampleTest.java
Normal file
@ -0,0 +1,68 @@
|
||||
//package org.example;
|
||||
//
|
||||
//import jdk.jfr.Event;
|
||||
//import org.hibernate.Session;
|
||||
//import org.hibernate.SessionFactory;
|
||||
//import org.hibernate.boot.MetadataSources;
|
||||
//import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
//import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.jupiter.api.AfterEach;
|
||||
//import org.junit.jupiter.api.BeforeEach;
|
||||
//import org.junit.jupiter.api.Disabled;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static org.hamcrest.MatcherAssert.assertThat;
|
||||
//
|
||||
//public class HibernateExampleTest {
|
||||
// private SessionFactory sessionFactory;
|
||||
//
|
||||
// @BeforeEach
|
||||
// protected void setUp() {
|
||||
// // A SessionFactory is set up once for an application!
|
||||
// final StandardServiceRegistry registry =
|
||||
// new StandardServiceRegistryBuilder()
|
||||
// .build();
|
||||
// try {
|
||||
// sessionFactory =
|
||||
// new MetadataSources(registry)
|
||||
// .addAnnotatedClass(Event.class)
|
||||
// .buildMetadata()
|
||||
// .buildSessionFactory();
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// // The registry would be destroyed by the SessionFactory, but we
|
||||
// // had trouble building the SessionFactory so destroy it manually.
|
||||
// StandardServiceRegistryBuilder.destroy(registry);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// @AfterEach
|
||||
//// protected void tearDown() throws Exception {
|
||||
//// if ( sessionFactory != null ) {
|
||||
//// sessionFactory.close();
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// @Test
|
||||
// public void postgres_fetch_actors() {
|
||||
// try (Session session = sessionFactory.getCurrentSession()) {
|
||||
// session.beginTransaction();
|
||||
//
|
||||
// List<Actor> actors = session.createQuery("select a from Actor a", Actor.class).list();
|
||||
// actors.forEach(System.out::println);
|
||||
//
|
||||
//
|
||||
// session.getTransaction().commit();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// @Test
|
||||
//// @Disabled
|
||||
//// public void how_does_hibernate_work() {
|
||||
//// Actor actor = null;
|
||||
//// assertThat(actor.getFirstName()).isEqualTo("Penelope");
|
||||
//// }
|
||||
//}
|
Loading…
Reference in New Issue
Block a user