-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |
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> |
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> |
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> |
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(); | ||
} | ||
} | ||
} |
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; | ||
} | ||
} |