用于DB连接的JDO类持久性

时间:2015-04-26 08:19:21

标签: spring persistence jdo querydsl

我是

的新手
org.datanucleus.store.rdbms.query.JDOQLQuery.compileQueryFull Query for 
candidates of com.titas.model.User_login and subclasses resulted in no 
possible candidates
Persistent class "com.titas.model.User_login" has no table in the 
database, but the operation requires it. Please check the specification 
of the MetaData for this class.
org.datanucleus.store.rdbms.exceptions.NoTableManagedException: 
Persistent class "com.titas.model.User_login" has no table in the 
database, but the operation requires it. Please check the specification 
of the MetaData for this class. 
at      
org.datanucleus.store.rdbms.RDBMSStoreManager.getDatastoreClass
(RDBMSStoreManager.java:693)
at   org.datanucleus.store.rdbms.query.RDBMSQueryUtils.getStatementFor
Candidates(RDBMSQueryUtils.java:425)

我的调度程序servlet是:

<!-- PMF Bean -->
<bean id="myPmf" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
    <property name="jdoPropertyMap">
            <props>
                <prop key="javax.jdo.PersistenceManagerFactoryClass">org.datanucleus.api.jdo.JDOPersistenceManagerFactory</prop>
                <prop key="javax.jdo.option.ConnectionDriverName">com.mysql.jdbc.Driver</prop>
                <prop key="javax.jdo.option.ConnectionURL">jdbc:mysql://localhost:3306/login</prop>
                <prop key="javax.jdo.option.ConnectionUserName">root</prop>
                <prop key="javax.jdo.option.NontransactionalRead">true</prop>                   
                <prop name="javax.jdo.option.NontransactionalWrite" value="true"></prop>
                <prop key="javax.jdo.option.RetainValues">false</prop>
                <prop key="javax.jdo.option.DetachAllOnCommit">true</prop>
                <prop key="javax.jdo.option.Multithreaded">true</prop>
            </props>
    </property>
</bean>

<!--<bean id="pmfProxy" class="org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy">
<property name="targetPersistenceManagerFactory" ref="myPmf"/>
<property name="allowCreate" value="false"/>
</bean>  --> 


<bean id="txManager" class="org.springframework.orm.jdo.JdoTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    <property name="persistenceManagerFactory" ref="myPmf"/>
</bean>



<bean id="userDAO" class="com.titas.dao.UserDAOImpl" >
</bean>

DAOImpl:

@Autowired
@Qualifier("dataSource")
private DataSource dataSource; 
@Autowired
@Qualifier("myPmf")
private PersistenceManagerFactory pmf;

HttpServletRequest request;

@Override
@Transactional
public List<User_login> getUser(String username, String userpassword) {
    PersistenceManager pm = this.pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;       
    try {
    // Start the transaction
    tx.begin(); 

    TypesafeQuery<User_login> tq = jdopm.newTypesafeQuery(User_login.class);
    QUser_login user = QUser_login.candidate();
    List<User_login> result = tq.filter(user.user_name.eq(username).and(user.user_password.eq(userpassword))).executeList();


    if(result.size()>0){
        log.info(">>>>>00000000");
    }else{
        log.info("<<<<<<<=====000000");
    }
    // Commit the transaction, flushing the object to the datastore
    tx.commit();
    return result;
    }
    finally {
        if (tx.isActive())
        {
            // Error occurred so rollback the transaction
            tx.rollback();
        }
        pm.close();
    } 

User.java:

@PersistenceCapable(table = "user_login")
public class User_login {  
@PrimaryKey
@Column(name="user_id")
private Integer user_id=0;
@Column(name="user_profile_name")
private String user_profile_name=null; 
@Column(name="user_email")
private String user_email=null;
@Column(name="user_contact")
private String user_contact=null;
@Column(name="user_name")
private String user_name=null;
@Column(name="user_password")
private String user_password=null;
@Column(name="user_role_id")
private Integer user_role_id=0;

我的依赖关系是: datanucleus-core,datanucleus-rdbms,datanucleus-api-jdo,datanucleus-jdo-query,jdo-api

来自DB的表识别失败。我不确定我的坚持。请帮忙!!

0 个答案:

没有答案