2020.1.2tangnan

master
1443155017@qq.com 5 years ago
parent 43dc291858
commit 27edceabeb

@ -0,0 +1,13 @@
<component name="ArtifactManager">
<artifact type="exploded-war" name="HibernateDamo:war exploded">
<output-path>$PROJECT_DIR$/out/artifacts/HibernateDamo_war_exploded</output-path>
<root id="root">
<element id="javaee-facet-resources" facet="HibernateDamo/web/Web" />
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="HibernateDamo" />
</element>
</element>
</root>
</artifact>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="8" />
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal">
<data-source name="xianshu@localhost" uuid="f04c8927-a966-444e-85ca-60ef5b013a3e">
<database-info product="MySQL" version="8.0.16" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-java-8.0.15 (Revision: 79a4336f140499bd22dd07f02b708e163844e3d5)" dbms="MYSQL" exact-version="8.0.16" exact-driver-version="8.0">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="lower" quoted-identifiers="lower" />
<secret-storage>master_key</secret-storage>
<user-name>root</user-name>
<schema-mapping>
<introspection-scope>
<node kind="schema" qname="@" />
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="xianshu@localhost" uuid="f04c8927-a966-444e-85ca-60ef5b013a3e">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/xianshu</jdbc-url>
<driver-properties>
<property name="autoReconnect" value="true" />
<property name="zeroDateTimeBehavior" value="CONVERT_TO_NULL" />
<property name="tinyInt1isBit" value="false" />
<property name="characterEncoding" value="utf8" />
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
</component>
</project>

@ -0,0 +1,27 @@
<component name="libraryTable">
<library name="Hibernate 5.4.9-5.4.9" type="hibernate">
<properties version="5.4.9" />
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/classmate-1.5.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/hibernate-commons-annotations-5.1.0.Final.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/istack-commons-runtime-3.0.7.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/FastInfoset-1.2.15.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.activation-api-1.2.0.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/antlr-2.7.7.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/jandex-2.1.1.Final.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/dom4j-2.1.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javassist-3.24.0-GA.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.persistence-api-2.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/jaxb-api-2.3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/jboss-transaction-api_1.2_spec-1.1.1.Final.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/stax-ex-1.8.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/jboss-logging-3.3.2.Final.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/txw2-2.3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/jaxb-runtime-2.3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/byte-buddy-1.10.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/hibernate-core-5.4.9.Final.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" />
</library>
</component>

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib (2)">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" />
</library>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/HibernateDamo.iml" filepath="$PROJECT_DIR$/HibernateDamo.iml" />
</modules>
</component>
</project>

@ -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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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>

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="112422a6-b7f7-4ea7-a2cb-16035012fff6" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DatabaseView">
<option name="SHOW_INTERMEDIATE" value="true" />
<option name="GROUP_DATA_SOURCES" value="true" />
<option name="GROUP_SCHEMA" value="true" />
<option name="GROUP_CONTENTS" value="false" />
<option name="SORT_POSITIONED" value="false" />
<option name="SHOW_EMPTY_GROUPS" value="false" />
<option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
<option name="HIDDEN_KINDS">
<set />
</option>
<expand>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="xianshu@localhost" type="feb32156:DbDataSourceImpl" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="xianshu@localhost" type="feb32156:DbDataSourceImpl" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="xianshu@localhost" type="feb32156:DbDataSourceImpl" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="xianshu: schema" type="76f4a085:MysqlImplModel$Schema" />
</path>
</expand>
<select />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="hibernate-configuration-5.2" />
<option value="hibernate-main-5.2" />
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="1VpNQTsimTghYCcxEtvoKr0YKl0" />
<component name="PropertiesComponent">
<property name="DatabaseDriversLRU" value="oracle&#10;mysql" />
<property name="Downloaded.Files.Path.Enabled" value="false" />
<property name="JPA.DatabaseSchemaImportDialog" value="f04c8927-a966-444e-85ca-60ef5b013a3e" />
<property name="Repository.Attach.Annotations" value="false" />
<property name="Repository.Attach.JavaDocs" value="false" />
<property name="Repository.Attach.Sources" value="false" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/lib" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="reference.projectsettings.compiler.javacompiler" />
</component>
<component name="RecentsManager">
<key name="ImportMappingsDialog.RecentPackages">
<recent name="table" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\TANGNAN\IdeaProjects\HibernateDamo\lib" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="JUnit.StudentsTest">
<configuration name="StudentsTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="HibernateDamo" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="test.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="test" />
<option name="MAIN_CLASS_NAME" value="test.StudentsTest" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="StudentsTest.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="HibernateDamo" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="test.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="test" />
<option name="MAIN_CLASS_NAME" value="test.StudentsTest" />
<option name="METHOD_NAME" value="test" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="JUnit.StudentsTest" />
<item itemvalue="JUnit.StudentsTest.test" />
</list>
</recent_temporary>
</component>
<component name="ServiceViewManager">
<option name="allServicesViewState">
<serviceView>
<treeState>
<expand>
<path>
<item name="services root" type="e789fda9:ObjectUtils$Sentinel" />
<item name="com.intellij.execution.services.ServiceModel$ServiceGroupNode@1003e9a1" type="7427dc5b:ServiceModel$ServiceGroupNode" />
</path>
<path>
<item name="services root" type="e789fda9:ObjectUtils$Sentinel" />
<item name="com.intellij.execution.services.ServiceModel$ServiceGroupNode@1003e9a1" type="7427dc5b:ServiceModel$ServiceGroupNode" />
<item name="com.intellij.execution.services.ServiceModel$ServiceNode@345cc67f" type="9fbbdea:ServiceModel$ServiceNode" />
</path>
</expand>
<select />
</treeState>
</serviceView>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="112422a6-b7f7-4ea7-a2cb-16035012fff6" name="Default Changelist" comment="" />
<created>1577946059823</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1577946059823</updated>
<workItem from="1577946063922" duration="5720000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
</project>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="hibernate" name="Hibernate">
<configuration>
<datasource-map>
<unit-entry name="hibernate.cfg.xml" value="f04c8927-a966-444e-85ca-60ef5b013a3e" />
</datasource-map>
<naming-strategy-map />
<deploymentDescriptor name="hibernate.cfg.xml" url="file://$MODULE_DIR$/src/hibernate.cfg.xml" />
</configuration>
</facet>
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Hibernate 5.4.9-5.4.9" level="project" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="lib (2)" level="project" />
</component>
</module>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,27 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/xianshu</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<mapping resource="table/BookEntity.hbm.xml"/>
<mapping class="table.BookEntity"/>
<mapping resource="table/OrderEntity.hbm.xml"/>
<mapping class="table.OrderEntity"/>
<mapping resource="table/ShopcartEntity.hbm.xml"/>
<mapping class="table.ShopcartEntity"/>
<mapping resource="table/UserEntity.hbm.xml"/>
<mapping class="table.UserEntity"/>
<!-- <property name="connection.username"/> -->
<!-- <property name="connection.password"/> -->
<!-- DB schema will be updated if needed -->
<!-- <property name="hibernate.hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.BookEntity" table="book" schema="xianshu">
<id name="bookid" column="bookid"/>
<property name="bookname" column="bookname"/>
<property name="price" column="price"/>
<property name="category" column="category"/>
<property name="imageurl" column="imageurl"/>
<property name="sellerId" column="sellerID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.OrderEntity" table="order" schema="xianshu">
<id name="orderId" column="orderId"/>
<property name="buyerId" column="BuyerID"/>
<property name="sellerId" column="sellerID"/>
<property name="bookId" column="bookID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.ShopcartEntity" table="shopcart" schema="xianshu">
<id name="cartId" column="cartID"/>
<property name="userId" column="userID"/>
<property name="bookid" column="bookid"/>
</class>
</hibernate-mapping>

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.UserEntity" table="user" schema="xianshu">
<id name="userId" column="userID"/>
<property name="userName" column="userName"/>
<property name="password" column="password"/>
<property name="school" column="school"/>
<property name="sex" column="sex"/>
</class>
</hibernate-mapping>

@ -0,0 +1,47 @@
import org.hibernate.HibernateException;
import org.hibernate.Metamodel;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import javax.persistence.metamodel.EntityType;
import java.util.Map;
public class Main {
private static final SessionFactory ourSessionFactory;
static {
try {
Configuration configuration = new Configuration();
configuration.configure();
ourSessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
try {
System.out.println("querying all the managed entities...");
final Metamodel metamodel = session.getSessionFactory().getMetamodel();
for (EntityType<?> entityType : metamodel.getEntities()) {
final String entityName = entityType.getName();
final Query query = session.createQuery("from " + entityName);
System.out.println("executing: " + query.getQueryString());
for (Object o : query.list()) {
System.out.println(" " + o);
}
}
} finally {
session.close();
}
}
}

@ -0,0 +1,27 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/xianshu</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<mapping resource="table/BookEntity.hbm.xml"/>
<mapping class="table.BookEntity"/>
<mapping resource="table/OrderEntity.hbm.xml"/>
<mapping class="table.OrderEntity"/>
<mapping resource="table/ShopcartEntity.hbm.xml"/>
<mapping class="table.ShopcartEntity"/>
<mapping resource="table/UserEntity.hbm.xml"/>
<mapping class="table.UserEntity"/>
<!-- <property name="connection.username"/> -->
<!-- <property name="connection.password"/> -->
<!-- DB schema will be updated if needed -->
<!-- <property name="hibernate.hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.BookEntity" table="book" schema="xianshu">
<id name="bookid" column="bookid"/>
<property name="bookname" column="bookname"/>
<property name="price" column="price"/>
<property name="category" column="category"/>
<property name="imageurl" column="imageurl"/>
<property name="sellerId" column="sellerID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,93 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "book", schema = "xianshu", catalog = "")
public class BookEntity {
private int bookid;
private String bookname;
private Integer price;
private String category;
private String imageurl;
private Integer sellerId;
@Id
@Column(name = "bookid")
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
@Basic
@Column(name = "bookname")
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
@Basic
@Column(name = "price")
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
@Basic
@Column(name = "category")
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Basic
@Column(name = "imageurl")
public String getImageurl() {
return imageurl;
}
public void setImageurl(String imageurl) {
this.imageurl = imageurl;
}
@Basic
@Column(name = "sellerID")
public Integer getSellerId() {
return sellerId;
}
public void setSellerId(Integer sellerId) {
this.sellerId = sellerId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BookEntity that = (BookEntity) o;
return bookid == that.bookid &&
Objects.equals(bookname, that.bookname) &&
Objects.equals(price, that.price) &&
Objects.equals(category, that.category) &&
Objects.equals(imageurl, that.imageurl) &&
Objects.equals(sellerId, that.sellerId);
}
@Override
public int hashCode() {
return Objects.hash(bookid, bookname, price, category, imageurl, sellerId);
}
}

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.OrderEntity" table="order" schema="xianshu">
<id name="orderId" column="orderId"/>
<property name="buyerId" column="BuyerID"/>
<property name="sellerId" column="sellerID"/>
<property name="bookId" column="bookID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,69 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "order", schema = "xianshu", catalog = "")
public class OrderEntity {
private int orderId;
private Integer buyerId;
private Integer sellerId;
private Integer bookId;
@Id
@Column(name = "orderId")
public int getOrderId() {
return orderId;
}
public void setOrderId(int orderId) {
this.orderId = orderId;
}
@Basic
@Column(name = "BuyerID")
public Integer getBuyerId() {
return buyerId;
}
public void setBuyerId(Integer buyerId) {
this.buyerId = buyerId;
}
@Basic
@Column(name = "sellerID")
public Integer getSellerId() {
return sellerId;
}
public void setSellerId(Integer sellerId) {
this.sellerId = sellerId;
}
@Basic
@Column(name = "bookID")
public Integer getBookId() {
return bookId;
}
public void setBookId(Integer bookId) {
this.bookId = bookId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OrderEntity that = (OrderEntity) o;
return orderId == that.orderId &&
Objects.equals(buyerId, that.buyerId) &&
Objects.equals(sellerId, that.sellerId) &&
Objects.equals(bookId, that.bookId);
}
@Override
public int hashCode() {
return Objects.hash(orderId, buyerId, sellerId, bookId);
}
}

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.ShopcartEntity" table="shopcart" schema="xianshu">
<id name="cartId" column="cartID"/>
<property name="userId" column="userID"/>
<property name="bookid" column="bookid"/>
</class>
</hibernate-mapping>

@ -0,0 +1,57 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "shopcart", schema = "xianshu", catalog = "")
public class ShopcartEntity {
private int cartId;
private Integer userId;
private Integer bookid;
@Id
@Column(name = "cartID")
public int getCartId() {
return cartId;
}
public void setCartId(int cartId) {
this.cartId = cartId;
}
@Basic
@Column(name = "userID")
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@Basic
@Column(name = "bookid")
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ShopcartEntity that = (ShopcartEntity) o;
return cartId == that.cartId &&
Objects.equals(userId, that.userId) &&
Objects.equals(bookid, that.bookid);
}
@Override
public int hashCode() {
return Objects.hash(cartId, userId, bookid);
}
}

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.UserEntity" table="user" schema="xianshu">
<id name="userId" column="userID"/>
<property name="userName" column="userName"/>
<property name="password" column="password"/>
<property name="school" column="school"/>
<property name="sex" column="sex"/>
</class>
</hibernate-mapping>

@ -0,0 +1,81 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "user", schema = "xianshu", catalog = "")
public class UserEntity {
private int userId;
private String userName;
private String password;
private String school;
private String sex;
@Id
@Column(name = "userID")
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Basic
@Column(name = "userName")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Basic
@Column(name = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "school")
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
@Basic
@Column(name = "sex")
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserEntity that = (UserEntity) o;
return userId == that.userId &&
Objects.equals(userName, that.userName) &&
Objects.equals(password, that.password) &&
Objects.equals(school, that.school) &&
Objects.equals(sex, that.sex);
}
@Override
public int hashCode() {
return Objects.hash(userId, userName, password, school, sex);
}
}

@ -0,0 +1,68 @@
package test;
import table.BookEntity;
import org.hibernate.*;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.Date;
/**
*
*/
public class StudentsTest {
private SessionFactory sessionFactory;
private Session session;
private Transaction transaction;
@Before
public void init(){
//创建配置对象
Configuration config = new Configuration().configure();
//创建服务注册对象
// ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();使用这种方法会报错unkonw Entity 。。。。)
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
//创建会话工厂对象
sessionFactory = config.buildSessionFactory(serviceRegistry);
//创建会话对象
session = sessionFactory.openSession();
//开启事务
transaction = session.beginTransaction();
}
@Test
public void testSaveStudents(){
BookEntity s = new BookEntity();
s.setBookid(2);
s.setBookname("李丽丽啊");
s.setPrice(10);
s.setCategory("语文");
session.save(s);//保存对象进入数据库
}
@After
public void destory(){
//提交事务
transaction.commit();
//关闭session
try {
session.close();
}catch(Exception e){
}
//关闭sessionFactory
sessionFactory.close();
}
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>

@ -0,0 +1,16 @@
<%--
Created by IntelliJ IDEA.
User: TANGNAN
Date: 2020/1/2
Time: 14:21
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>

@ -0,0 +1,47 @@
import org.hibernate.HibernateException;
import org.hibernate.Metamodel;
import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import javax.persistence.metamodel.EntityType;
import java.util.Map;
public class Main {
private static final SessionFactory ourSessionFactory;
static {
try {
Configuration configuration = new Configuration();
configuration.configure();
ourSessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
try {
System.out.println("querying all the managed entities...");
final Metamodel metamodel = session.getSessionFactory().getMetamodel();
for (EntityType<?> entityType : metamodel.getEntities()) {
final String entityName = entityType.getName();
final Query query = session.createQuery("from " + entityName);
System.out.println("executing: " + query.getQueryString());
for (Object o : query.list()) {
System.out.println(" " + o);
}
}
} finally {
session.close();
}
}
}

@ -0,0 +1,27 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/xianshu</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<mapping resource="table/BookEntity.hbm.xml"/>
<mapping class="table.BookEntity"/>
<mapping resource="table/OrderEntity.hbm.xml"/>
<mapping class="table.OrderEntity"/>
<mapping resource="table/ShopcartEntity.hbm.xml"/>
<mapping class="table.ShopcartEntity"/>
<mapping resource="table/UserEntity.hbm.xml"/>
<mapping class="table.UserEntity"/>
<!-- <property name="connection.username"/> -->
<!-- <property name="connection.password"/> -->
<!-- DB schema will be updated if needed -->
<!-- <property name="hibernate.hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.BookEntity" table="book" schema="xianshu">
<id name="bookid" column="bookid"/>
<property name="bookname" column="bookname"/>
<property name="price" column="price"/>
<property name="category" column="category"/>
<property name="imageurl" column="imageurl"/>
<property name="sellerId" column="sellerID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,93 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "book", schema = "xianshu", catalog = "")
public class BookEntity {
private int bookid;
private String bookname;
private Integer price;
private String category;
private String imageurl;
private Integer sellerId;
@Id
@Column(name = "bookid")
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
@Basic
@Column(name = "bookname")
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
@Basic
@Column(name = "price")
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
@Basic
@Column(name = "category")
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Basic
@Column(name = "imageurl")
public String getImageurl() {
return imageurl;
}
public void setImageurl(String imageurl) {
this.imageurl = imageurl;
}
@Basic
@Column(name = "sellerID")
public Integer getSellerId() {
return sellerId;
}
public void setSellerId(Integer sellerId) {
this.sellerId = sellerId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BookEntity that = (BookEntity) o;
return bookid == that.bookid &&
Objects.equals(bookname, that.bookname) &&
Objects.equals(price, that.price) &&
Objects.equals(category, that.category) &&
Objects.equals(imageurl, that.imageurl) &&
Objects.equals(sellerId, that.sellerId);
}
@Override
public int hashCode() {
return Objects.hash(bookid, bookname, price, category, imageurl, sellerId);
}
}

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.OrderEntity" table="order" schema="xianshu">
<id name="orderId" column="orderId"/>
<property name="buyerId" column="BuyerID"/>
<property name="sellerId" column="sellerID"/>
<property name="bookId" column="bookID"/>
</class>
</hibernate-mapping>

@ -0,0 +1,69 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "order", schema = "xianshu", catalog = "")
public class OrderEntity {
private int orderId;
private Integer buyerId;
private Integer sellerId;
private Integer bookId;
@Id
@Column(name = "orderId")
public int getOrderId() {
return orderId;
}
public void setOrderId(int orderId) {
this.orderId = orderId;
}
@Basic
@Column(name = "BuyerID")
public Integer getBuyerId() {
return buyerId;
}
public void setBuyerId(Integer buyerId) {
this.buyerId = buyerId;
}
@Basic
@Column(name = "sellerID")
public Integer getSellerId() {
return sellerId;
}
public void setSellerId(Integer sellerId) {
this.sellerId = sellerId;
}
@Basic
@Column(name = "bookID")
public Integer getBookId() {
return bookId;
}
public void setBookId(Integer bookId) {
this.bookId = bookId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OrderEntity that = (OrderEntity) o;
return orderId == that.orderId &&
Objects.equals(buyerId, that.buyerId) &&
Objects.equals(sellerId, that.sellerId) &&
Objects.equals(bookId, that.bookId);
}
@Override
public int hashCode() {
return Objects.hash(orderId, buyerId, sellerId, bookId);
}
}

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.ShopcartEntity" table="shopcart" schema="xianshu">
<id name="cartId" column="cartID"/>
<property name="userId" column="userID"/>
<property name="bookid" column="bookid"/>
</class>
</hibernate-mapping>

@ -0,0 +1,57 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "shopcart", schema = "xianshu", catalog = "")
public class ShopcartEntity {
private int cartId;
private Integer userId;
private Integer bookid;
@Id
@Column(name = "cartID")
public int getCartId() {
return cartId;
}
public void setCartId(int cartId) {
this.cartId = cartId;
}
@Basic
@Column(name = "userID")
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@Basic
@Column(name = "bookid")
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ShopcartEntity that = (ShopcartEntity) o;
return cartId == that.cartId &&
Objects.equals(userId, that.userId) &&
Objects.equals(bookid, that.bookid);
}
@Override
public int hashCode() {
return Objects.hash(cartId, userId, bookid);
}
}

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="table.UserEntity" table="user" schema="xianshu">
<id name="userId" column="userID"/>
<property name="userName" column="userName"/>
<property name="password" column="password"/>
<property name="school" column="school"/>
<property name="sex" column="sex"/>
</class>
</hibernate-mapping>

@ -0,0 +1,81 @@
package table;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "user", schema = "xianshu", catalog = "")
public class UserEntity {
private int userId;
private String userName;
private String password;
private String school;
private String sex;
@Id
@Column(name = "userID")
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Basic
@Column(name = "userName")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Basic
@Column(name = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "school")
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
@Basic
@Column(name = "sex")
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserEntity that = (UserEntity) o;
return userId == that.userId &&
Objects.equals(userName, that.userName) &&
Objects.equals(password, that.password) &&
Objects.equals(school, that.school) &&
Objects.equals(sex, that.sex);
}
@Override
public int hashCode() {
return Objects.hash(userId, userName, password, school, sex);
}
}

@ -0,0 +1,68 @@
package test;
import table.BookEntity;
import org.hibernate.*;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.Date;
/**
*
*/
public class StudentsTest {
private SessionFactory sessionFactory;
private Session session;
private Transaction transaction;
@Before
public void init(){
//创建配置对象
Configuration config = new Configuration().configure();
//创建服务注册对象
// ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();使用这种方法会报错unkonw Entity 。。。。)
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
//创建会话工厂对象
sessionFactory = config.buildSessionFactory(serviceRegistry);
//创建会话对象
session = sessionFactory.openSession();
//开启事务
transaction = session.beginTransaction();
}
@Test
public void testSaveStudents(){
BookEntity s = new BookEntity();
s.setBookid(2);
s.setBookname("李丽丽啊");
s.setPrice(10);
s.setCategory("语文");
session.save(s);//保存对象进入数据库
}
@After
public void destory(){
//提交事务
transaction.commit();
//关闭session
try {
session.close();
}catch(Exception e){
}
//关闭sessionFactory
sessionFactory.close();
}
}
Loading…
Cancel
Save