I have a gwt project that already uses Hibernate successfully. The
project is basically just retrieving info from one table for
authentication. Im not eving trying the web aspect of this out right
now. Im trying transactional method first, since this seems the
easiest way to use warp persist.
When I try to run the program I get this error
Exception in thread "main" org.hibernate.HibernateException:
createQuery is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext
$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:
338)
at $Proxy7.createQuery(Unknown Source)
at com.wideplay.warp.hibernate.HibernateFinderInterceptor
$FinderDescriptor.createQuery(HibernateFinderInterceptor.java:256)
at com.wideplay.warp.hibernate.HibernateFinderInterceptor.invoke
(HibernateFinderInterceptor.java:68)
at com.google.inject.InterceptorStackCallback
$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
at com.google.inject.InterceptorStackCallback.intercept
(InterceptorStackCallback.java:44)
at org.webhop.ywdc.login.client.LoginRepository$$EnhancerByGuice$
$76a2c7f1.listall(<generated>)
at org.webhop.ywdc.login.client.Main.main(Main.java:46)
Heres my main method that I use to enstantiate the Injector and do all
my business:
public static void main(String[] args)
{
Injector injector = Guice.createInjector(new LoginModule(),
PersistenceService
.usingHibernate()
.across(UnitOfWork.TRANSACTION)
.buildModule());
LoginRepository lRepository = injector.getInstance
(LoginRepository.class);
Vector<Members> repositoryList = lRepository.listall();
for (Members c : repositoryList)
{
System.out.println(c.getUsername());
}
}
Here is my Repository
@Transactional
public class LoginRepository {
public void LoginRespository(){}
@Inject
Provider<Session> session;
@Finder(query="from Members")
public Vector<Members> listall()
{
return null;
}
Here is my Guice module:
public class LoginModule extends AbstractModule {
@Override
protected void configure()
{
bind(Configuration.class).toInstance(new AnnotationConfiguration
().addResource("hibernate.cfg.xml"));
bind(MyInitializer.class).asEagerSingleton();
//bind(Session.class).asEagerSingleton();
bind(LoginRepository.class).asEagerSingleton();
}
}
Now I dont know why the error report says that createQuery is not
valid without active transaction, because I bound my Initializer class
"MyInitializer" in as an eager singleton just like the warppersist
site said to do, which would make it available when guice started.
heres is that initializer class:
public class MyInitializer {
@Inject
MyInitializer(PersistenceService service)
{
service.start();
}
}
I really really would appreciate a bit of help with this one.
Sincerely,
Coder420
--
You received this message because you are subscribed to the Google Groups "warp-core" group.
To post to this group, send email to warp...@googlegroups.com.
To unsubscribe from this group, send email to warp-core+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/warp-core?hl=en.