hibernate - Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: user lacks privilege -


seems don't know lack. after running junit test, got this

caused by: org.apache.openjpa.lib.jdbc.reportingsqlexception: user lacks privilege or object not found: dtb_tablename {insert ....

does have database? or code itself?

here codes:

persistence.xml

<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="myrestapi" transaction-type="jta">     <class>com.rest.entity.tablenamebean</class>      <jta-data-source>mydatasource</jta-data-source>     <properties>         <property name="hibernate.hbm2ddl.auto" value="update" />         <property name="hibernate.dialect">org.hibernate.dialect.mysqldialect</property>         <property name="hibernate.show_sql" value="true" />     </properties>  </persistence-unit> 

mygenericdao

public abstract class mygenericdao<t, id extends serializable> implements genericdao<t, id> {  private class<t> persistentclass;  @suppresswarnings("unchecked") public mygenericdao() {     this.persistentclass = (class<t>) ((parameterizedtype) getclass()             .getgenericsuperclass()).getactualtypearguments()[0]; }  public abstract entitymanager getentitymanager();  public class<t> getpersistentclass() {     return persistentclass; } //.... //....  @suppresswarnings("unchecked") public t findbyid(id id, boolean lock) {     if(lock)         return getentitymanager().find(getpersistentclass(), id, lockmodetype.pessimistic_write);     else         return getentitymanager().find(getpersistentclass(), id); }  public t makepersistent(t entity) {     getentitymanager().persist(entity);     return entity; } 

[tablename]dao

 @singleton public class tablenamedao extends genericjpadao<tablenamebean, integer>{  @persistencecontext(unitname="myrestapi") private entitymanager em;  @override public entitymanager getentitymanager() {     return em; }   } 

then, tablenamedaotest

public class tablenamedaotest {  private static ejbcontainer container;  @ejb private tablenamedao tablenamedao;  @test public void testfindbyid() {     tablenamebean tablebean = tablenamedao.findbyid(1, false);     assertnotnull(tablebean); }  @test public void testfindall() {     fail("not yet implemented"); }  @test public void testmakepersistent() {     tablenamebean tablebean = new tablenamebean();     tablebean.setloginname("testname");     tablebean.setpassword("password");      tablenamedao.makepersistent(tablebean);     assertnotnull(tablebean.getaccountid()); }  @beforeclass public static void start() {     container = ejbcontainer.createejbcontainer(); }  @before public void inject() throws namingexception {     container.getcontext().bind("inject", this); }  @afterclass public static void stop() {     container.close(); } 

any on one, please? lot. btw, im running on tomee , database mysql. i've configured database url, driver, username , password in tomee.xml. i've imported server folder , published.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -