Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shaozhb authored and shaozhb committed Dec 4, 2017
0 parents commit 8ca122d
Show file tree
Hide file tree
Showing 54 changed files with 456 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .idea/artifacts/infopublish_war_exploded.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/dataSources/aec620f3-eb36-43fc-b7b1-ad6288121cc1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/libraries/Hibernate_5_2_12_5_2_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions .idea/libraries/Spring_4_3_13_RELEASE.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/libraries/Struts_2_2_5_13.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions config/hibernate/Info.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping">
<class name="cn.shao.infopublish.bean.Info" table="tb_info" catalog="infopublish">
<id name="id" type="java.lang.String">
<column name="id"/>
<generator class="uuid"/>
</id>
<many-to-one name="user" class="cn.shao.infopublish.bean.User" fetch="select">
<column name="FK_user_id"/>
</many-to-one>
<property name="title" unique="true">
<column name="title"/>
</property>
<property name="pubDate">
<column name="pub_date"/>
</property>
<property name="content">
<column name="content" length="1000"></column>
</property>
<property name="accessoryName">
<column name="accessoryName"/>
</property>
<property name="accessoryURL">
<column name="accessoryURL"/>
</property>
</class>
</hibernate-mapping>
14 changes: 14 additions & 0 deletions config/hibernate/User.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping">
<class name="cn.shao.infopublish.bean.User" table="tb_user" catalog="infopublish">
<id name="id" type="java.lang.String">
<column name="ID"/>
<generator class="uuid"/>
</id>
<property name="name" unique="true">
<column name="username"/>
</property>
<property name="password">
<column name="password"/>
</property>
</class>
</hibernate-mapping>
16 changes: 16 additions & 0 deletions config/hibernate/hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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"/>
<property name="connection.driver_class"/>

<!-- <property name="connection.username"/> -->
<!-- <property name="connection.password"/> -->

<!-- DB schema will be updated if needed -->
<!-- <property name="hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>
51 changes: 51 additions & 0 deletions infopublish.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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" />
</datasource-map>
<naming-strategy-map />
<deploymentDescriptor name="hibernate.cfg.xml" url="file://$MODULE_DIR$/config/hibernate/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 type="Struts2" name="Struts 2">
<configuration>
<fileset id="s2fileset" name="Default File Set " removed="false">
<file>file://$MODULE_DIR$/src/struts.xml</file>
<file>jar://$MODULE_DIR$/lib/struts2-core.jar!/struts-default.xml</file>
</fileset>
<propertiesKeys disabled="false" />
</configuration>
</facet>
</facet>
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset" name="Spring Application Context" removed="false">
<file>file://$MODULE_DIR$/src/spring-config.xml</file>
</fileset>
</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.2.12-5.2.12" level="project" />
<orderEntry type="library" name="Spring-4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Struts 2-2.5.13" level="project" />
</component>
</module>
Binary file added lib/antlr-2.7.7.jar
Binary file not shown.
Binary file added lib/aopalliance-1.0.jar
Binary file not shown.
Binary file added lib/classmate-1.3.0.jar
Binary file not shown.
Binary file added lib/commons-fileupload.jar
Binary file not shown.
Binary file added lib/commons-io.jar
Binary file not shown.
Binary file added lib/commons-lang.jar
Binary file not shown.
Binary file added lib/commons-logging-1.2.jar
Binary file not shown.
Binary file added lib/dom4j-1.6.1.jar
Binary file not shown.
Binary file added lib/freemarker.jar
Binary file not shown.
Binary file added lib/hibernate-commons-annotations-5.0.1.Final.jar
Binary file not shown.
Binary file added lib/hibernate-core-5.2.12.Final.jar
Binary file not shown.
Binary file added lib/hibernate-jpa-2.1-api-1.0.0.Final.jar
Binary file not shown.
Binary file added lib/jandex-2.0.3.Final.jar
Binary file not shown.
Binary file added lib/javassist-3.20.0-GA.jar
Binary file not shown.
Binary file added lib/jboss-logging-3.3.0.Final.jar
Binary file not shown.
Binary file not shown.
Binary file added lib/ognl.jar
Binary file not shown.
Binary file added lib/spring-aop-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-aspects-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-beans-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-context-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-context-support-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-core-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-expression-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-instrument-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-instrument-tomcat-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-jdbc-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-jms-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-messaging-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-orm-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-oxm-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-test-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/spring-tx-4.3.13.RELEASE.jar
Binary file not shown.
Binary file added lib/struts2-annotations.jar
Binary file not shown.
Binary file added lib/struts2-core.jar
Binary file not shown.
45 changes: 45 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import org.hibernate.HibernateException;
import org.hibernate.Metamodel;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.query.Query;

import javax.persistence.metamodel.EntityType;

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();
}
}
}
71 changes: 71 additions & 0 deletions src/cn/shao/infopublish/bean/Info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cn.shao.infopublish.bean;

import java.util.Date;

public class Info implements java.io.Serializable {
private String id;
private User user;
private String title;

public String getId() {
return id;
}

public User getUser() {
return user;
}

public String getTitle() {
return title;
}

public Date getPubDate() {
return pubDate;
}

public String getContent() {
return content;
}

public String getAccessoryName() {
return accessoryName;
}

public String getAccessoryURL() {
return accessoryURL;
}

private Date pubDate;

private String content;
private String accessoryName;
private String accessoryURL;

public void setId(String id) {
this.id = id;
}

public void setUser(User user) {
this.user = user;
}

public void setTitle(String title) {
this.title = title;
}

public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}

public void setContent(String content) {
this.content = content;
}

public void setAccessoryName(String accessoryName) {
this.accessoryName = accessoryName;
}

public void setAccessoryURL(String accessoryURL) {
this.accessoryURL = accessoryURL;
}
}
Loading

0 comments on commit 8ca122d

Please sign in to comment.