Skip to content

Commit

Permalink
add demo 7
Browse files Browse the repository at this point in the history
  • Loading branch information
waynelau committed Jul 27, 2014
1 parent 16555fc commit 59a0489
Show file tree
Hide file tree
Showing 90 changed files with 926 additions and 5 deletions.
Binary file not shown.
Expand Up @@ -10,7 +10,8 @@
<property name="connection.url">jdbc:jtds:sqlserver://192.168.1.10:1433;RestDemo</property>
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>


<property name="hibernate.default_schema">RestDemo.dbo</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
Expand Down
Expand Up @@ -103,7 +103,8 @@ public boolean updateUser(User user) {
}
return flag;
}


@SuppressWarnings("unchecked")
@Override
public List<User> getAllUsers() {
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Expand Down
3 changes: 2 additions & 1 deletion jersey-demo6-sqlserver-hibernate/src/hibernate.cfg.xml
Expand Up @@ -10,7 +10,8 @@
<property name="connection.url">jdbc:jtds:sqlserver://192.168.1.10:1433;RestDemo</property>
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>


<property name="hibernate.default_schema">RestDemo.dbo</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
Expand Down
Expand Up @@ -11,6 +11,8 @@
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>

<!-- <property name="hibernate.default_schema">RestDemo.dbo</property> -->

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

Expand Down
Expand Up @@ -115,8 +115,8 @@ public List<User> getAllUsers() {
t = s.beginTransaction();
String hql = "select * from [RestDemo].dbo.t_user";
Query query = s.createSQLQuery(hql).addEntity(User.class);
// String hql = " from User";
// Query query = s.createQuery(hql);
// String hql = " from User";
//Query query = s.createQuery(hql);
//query.setCacheable(true); // 设置缓存
uesrs = query.list();
t.commit();
Expand Down
2 changes: 2 additions & 0 deletions jersey-demo6.2-sqlserver-hibernate/src/hibernate.cfg.xml
Expand Up @@ -11,6 +11,8 @@
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>

<!-- <property name="hibernate.default_schema">RestDemo.dbo</property> -->

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

Expand Down
60 changes: 60 additions & 0 deletions jersey-demo7-sqlserver-hibernate-spring3/.classpath
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/aopalliance-repackaged-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/asm-debug-all-5.0.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hk2-api-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hk2-locator-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hk2-utils-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/javassist-3.18.1-GA.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/javax.annotation-api-1.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/javax.inject-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/javax.servlet-api-3.0.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/javax.ws.rs-api-2.0.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaxb-api-2.2.7.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-client.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-common.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-container-servlet-core.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-container-servlet.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-guava-2.10.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-server.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/org.osgi.core-4.2.0.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/osgi-resource-locator-1.0.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/persistence-api-1.0.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/validation-api-1.1.0.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jackson-all-1.9.11.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/antlr-2.7.7.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hibernate-commons-annotations-4.0.4.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hibernate-core-4.3.5.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jandex-1.1.0.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jboss-logging-3.1.3.GA.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jboss-logging-annotations-1.2.0.Beta1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jboss-transaction-api_1.2_spec-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jtds-1.2.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.12.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-aop-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-beans-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-bridge-2.3.0-b05.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-context-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-core-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-expression-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/spring-web-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jersey-spring3-2.10.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/aopalliance-1.0.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
36 changes: 36 additions & 0 deletions jersey-demo7-sqlserver-hibernate-spring3/.project
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jersey-demo7-sqlserver-hibernate-spring3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions jersey-demo7-sqlserver-hibernate-spring3/.settings/.jsdtscope
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="jersey-demo1-helloworld">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="java-output-path" value="/jersey-demo1-helloworld/build/classes"/>
<property name="context-root" value="RestDemo"/>
</wb-module>
</project-modules>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v7.0"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
@@ -0,0 +1 @@
Window
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>RestDemo</display-name>

<module-name>RestDemo</module-name>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<servlet>
<servlet-name>Way REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.waylau.rest.RestApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Way REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
>
<context:annotation-config></context:annotation-config>


<bean id="UserServiceImpl" class="com.waylau.rest.service.impl.UserServiceImpl"/>

<bean id="UserDaoImpl" class="com.waylau.rest.dao.impl.UserDaoImpl"/>

</beans>
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">


<hibernate-mapping package="com.waylau.rest.bean">

<!-- <class name="User" table="T_USER" schema="RestDemo.dbo"> -->
<class name="User" table="T_USER" >
<id name="userId" column="USERID" type="string" >
<generator class="assigned"/>
</id>
<property name="userName" type="string" />
<property name="age" type="string" />
</class>

</hibernate-mapping>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sqlserver://192.168.1.10:1433;RestDemo</property>
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>

<property name="hibernate.default_schema">RestDemo.dbo</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/waylau/rest/bean/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
>
<context:annotation-config></context:annotation-config>


<bean id="UserServiceImpl" class="com.waylau.rest.service.impl.UserServiceImpl"/>

<bean id="UserDaoImpl" class="com.waylau.rest.dao.impl.UserDaoImpl"/>

</beans>
@@ -0,0 +1,21 @@
package com.waylau.rest;

import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;

/**
* 应用
* @author waylau.com
* 2014-3-18
*/
public class RestApplication extends ResourceConfig {
public RestApplication() {

//服务类所在的包路径
packages("com.waylau.rest.resources");
//注册JSON转换器
register(JacksonJsonProvider.class);

}
}
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">


<hibernate-mapping package="com.waylau.rest.bean">

<!-- <class name="User" table="T_USER" schema="RestDemo.dbo"> -->
<class name="User" table="T_USER" >
<id name="userId" column="USERID" type="string" >
<generator class="assigned"/>
</id>
<property name="userName" type="string" />
<property name="age" type="string" />
</class>

</hibernate-mapping>

0 comments on commit 59a0489

Please sign in to comment.