이것은 내가 게시 한 첫 번째 질문이므로 모든 규칙이나 예의 범절을 위반하면 사전에 사과드립니다. 나는 다음과 같은 예외를 제거 할 수없는 것 :"명명 된 쿼리의 오류 : User.findByUserNameAndPassword"- 해결할 수 없음
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:257)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 79 more
Caused by: org.hibernate.HibernateException: Errors in named queries: User.findByUserNameAndPassword
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:426)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
내 명명 된 질의는 다음과 같습니다 가지고있는 엔티티 (! 나하려고)
@Entity
@Table(name="USERS")
@NamedQueries
({
@NamedQuery(name="User.findByUserNameAndPassword", query="SELECT u FROM User u WHERE u.username = :username AND u.password = :password")
})
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="USERS_ID_GENERATOR", sequenceName="PERSONAL.GLOBALSEQUENCE")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="USERS_ID_GENERATOR")
private long id;
private String notes;
@Column(name="PASSWORD")
private String password;
@Column(name="USERNAME")
private String username;
...
내가 실행하고 UserServiceImpl 클래스에서이 쿼리 같은
:
@Transactional(readOnly=true)
public User authenticate(String userName, String password) {
List<User> usersList = em.createQuery("User.findByUserNameAndPassword", User.class).setParameter("username", userName).setParameter("password", password).getResultList();
User firstUserFromList = usersList.get(0);
return firstUserFromList;
}
내가 그럴 필요있다 많은 일들이 있었지만 잠시 동안이 일에 매달 렸습니다. 도움이나 안내는 정말 감사하겠습니다.
내 applicationContext.xml 파일은 다음과 같습니다
환호 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">
<context:component-scan base-package="com.transience.sandbox" />
<mvc:annotation-driven />
<tx:annotation-driven />
<mvc:resources mapping="/static_resources/**" location="/static_resources/" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
</bean>
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /></property>
<property name="packagesToScan" value="com.transience.sandbox.domain"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<jee:jndi-lookup id="dataSource" jndi-name="oracleXEDS"/>
<jpa:repositories base-package="com.transience.sandbox.domain" entity-manager-factory-ref="emf" transaction-manager-ref="transactionManager"/>
</beans>
내가 Spring (core, webmvc, context, orm, jdbc, tx) 3.1
, Hibernate 3.6.8
, Spring-data-jpa 1.2.0
, Weblogic 12c
및 OracleXE
을 사용하고 있습니다. 그리고 메이븐.
config xml 파일을 보시려면 – Stuart
@pospeq, 정보가 –
인 게시물을 수정했습니다 @ user1268189 이것을 해결할 수 있었습니까? 내가 거의 2 년 동안 이걸 붙잡힌 것 같아. 내 문제는 다음과 같습니다. https://groups.google.com/forum/#!topic/play-framework/F3wFUbSYIog Play 프레임 워크와 관련이 있지만 잘못했는지 잘 모르겠습니다. 이 문제를 해결할 수 있는지 알려주세요. – user1242321