hibernate註解HQL 報錯

來源:互聯網
上載者:User

標籤:hibernate註解hql 報錯

@Entity(name="icertInfo") HQL  查詢的時候 需要寫Entry 的name值,要不然會報錯 iCertInfo is not mapped

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><!-- 使用者名稱 --><property name="user" value="${db_username}" /><!-- 使用者密碼 --><property name="password" value="${db_password}" /><property name="driverClass" value="${db_driver_class}" /><property name="jdbcUrl" value="${db_url}" /><!--串連池中保留的最大串連數。預設值: 15 --><property name="maxPoolSize" value="20" /><!-- 串連池中保留的最小串連數,預設為:3 --><property name="minPoolSize" value="5" /><!-- 初始化串連池中的串連數,取值應在minPoolSize與maxPoolSize之間,預設為3 --><property name="initialPoolSize" value="2" /><!--當串連池中的串連耗盡的時候c3p0一次同時擷取的串連數。預設值: 3 --><property name="acquireIncrement" value="2" /><!--定義在從資料庫擷取新串連失敗後重複嘗試的次數。預設值: 30 ;小於等於0表示無限次 --><property name="acquireRetryAttempts" value="0" /><!--重新嘗試的時間間隔,預設為:1000毫秒 --><property name="acquireRetryDelay" value="1000" /></bean><!-- 擷取hibernate SessionFactory --><bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><value>hibernate.dialect=org.hibernate.dialect.MySQLDialecthibernate.show_sql=truehibernate.format_sql=truehibernate.hbm2ddl.auto=update</value></property><property name="packagesToScan"><list><value>com.itrus.business.model</value></list></property></bean>

packagesToScan   ,配置錯誤 HQL 也會報錯


package com.itrus.business.properties;import java.util.HashMap;import java.util.Map;import java.util.Properties;import org.springframework.beans.BeansException;import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;public class ProInfo extends PropertyPlaceholderConfigurer {private static Map<String, Object> ctxPropertiesMap; @Override  protected void processProperties(ConfigurableListableBeanFactory beanFactory,              Properties props)throws BeansException {          super.processProperties(beanFactory, props);          ctxPropertiesMap = new HashMap<String, Object>();          for (Object key : props.keySet()) {              String keyStr = key.toString();              String value = props.getProperty(keyStr);              ctxPropertiesMap.put(keyStr, value);          }    }    public static Object getContextProperty(String name) {          return ctxPropertiesMap.get(name);      }}



URL=

#AccountHash=

AccountHash=

Password=password

fapiaotong=

certpath=E\://test.cer

db_username=root

#db_password=

db_password=

db_driver_class=com.mysql.jdbc.Driver

#db_url=jdbc\:mysql\://\:3306/hibernate?useUnicode\=true&characterEncoding\=UTF-8

db_url=jdbc\:mysql\://localhost\:3306/hibernate?useUnicode\=true&characterEncoding\=UTF-8

<!-- 讀取設定檔 --><bean id="proinfo" class="com.itrus.business.properties.ProInfo"><property name="locations"><list><value>classpath:info.properties</value></list></property></bean>



不配置包掃描 查詢需要寫全名 com.itrus.business.model.ICertInfo

hibernate註解HQL 報錯

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.