Announcement Announcement Module
Collapse
No announcement yet.
config spring 3.1.2 jpa 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • config spring 3.1.2 jpa 2.0

    lib use
    Attachment

    http://i1017.photobucket.com/albums/...ps7e5f334b.png

    applicationContext.xml
    Code:
    <bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="masterdata" />
    		<property name="dataSource" ref="dataSource" />
    		<property name="jpaVendorAdapter">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="showSql" value="true" />
    				<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
    			</bean>
    		</property>
    	</bean>
    
    	<bean id="dataSource"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
    		<property name="url"
    			value="jdbc:sqlserver://10.1.3.86\FMIS2:1433;databaseName=fmis2.0" />
    		<property name="username" value="erp" />
    		<property name="password" value="erp" />
    	</bean>
    	<context:component-scan base-package="com.evnit.fmis" />
    	<tx:annotation-driven transaction-manager="transactionManager"/>
    
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    	<bean id="persistenceAnnotation"
    		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    persistence.xml
    Code:
    <persistence-unit name="masterdata" transaction-type="RESOURCE_LOCAL">
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    	</persistence-unit>
    Code java Dao
    Code:
    @Repository("basicDao")
    public class BasicDao<T> {
    
    	@PersistenceContext(unitName = "masterdata")
    	protected EntityManager entityManager;
    
    	public List<T> getAll(Class<T> clazz) {
    		String query = "SELECT elm FROM DmDonvi elm";
    		return entityManager.createQuery(query).getResultList();
    	}
    }
    Entity
    Code:
    @Entity
    @Table(name = "DM_DONVI")
    public class DmDonvi implements java.io.Serializable {
    
    	// Fields
      .....................
    }
    call getAll from dao error

    Hibernate: select dmdonvi0_.ID as ID5_, dmdonvi0_.CLIENT_ID as CLIENT2_5_, dmdonvi0_.DIACHI as DIACHI5_, dmdonvi0_.DIENTHOAI as DIENTHOAI5_, dmdonvi0_.DMNGANHANGID as DMNGANH16_5_, dmdonvi0_.DONVICAPTREN_ID as DONVICAP5_5_, dmdonvi0_.EMAIL as EMAIL5_, dmdonvi0_.FAX as FAX5_, dmdonvi0_.MA as MA5_, dmdonvi0_.MASOTHUE as MASOTHUE5_, dmdonvi0_.NGAYCAPNHAT as NGAYCAP10_5_, dmdonvi0_.NGAYTAO as NGAYTAO5_, dmdonvi0_.NGUOICAPNHAT as NGUOICA12_5_, dmdonvi0_.TAIKHOAN as TAIKHOAN5_, dmdonvi0_.TEN as TEN5_, dmdonvi0_.TENTAT as TENTAT5_ from DM_DONVI dmdonvi0_
    2013-02-21 14:26:30,347 WARN [Thread-2] JDBCExceptionReporter M[logExceptions] --> SQL Error: 208, SQLState: S0002
    2013-02-21 14:26:30,348 ERROR [Thread-2] JDBCExceptionReporter M[logExceptions] --> Invalid object name 'DM_DONVI'.
    ..............
    Attachment file error
    Attached Files
    Last edited by longtqdayma; Feb 21st, 2013, 02:54 AM.
Working...
X