You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by tm...@gmx.de on 2011/03/28 11:24:23 UTC

Writing a commandline script that uses IOC+Hibernate

hello everyone!

i am trying to write a script that will use tapestry-hibernate to will do some database processing tasks from a command line. It also needs to access IOC Services:


public static void main(String[] args) {
		RegistryBuilder builder = new RegistryBuilder();
		builder.add(HibernateCoreModule.class);

		Registry registry = builder.build();
		registry.performRegistryStartup();

		HibernateSessionSource hello = registry
				.getService(HibernateSessionSource.class);
		Session session = hello.getSessionFactory().openSession();
		
		Something something = new Something();
		something.setName("test");

		session.persist(type);
		registry.cleanupThread();
		registry.shutdown();
	}

could it work like that or is there something fundamentally wrong here or missing?

thanks!

tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Writing a commandline script that uses IOC+Hibernate

Posted by Yury Luneff <bi...@ya.ru>.
> hello everyone!

> i am trying to write a script that will use tapestry-hibernate to
> will do some database processing tasks from a command line. It also needs to access IOC Services:


> public static void main(String[] args) {
>                 RegistryBuilder builder = new RegistryBuilder();
>                 builder.add(HibernateCoreModule.class);

>                 Registry registry = builder.build();
>                 registry.performRegistryStartup();

>                 HibernateSessionSource hello = registry
>                                
> .getService(HibernateSessionSource.class);
>                 Session session =
> hello.getSessionFactory().openSession();
>                 
>                 Something something = new Something();
>                 something.setName("test");

>                 session.persist(type);
session.getCurrentTransaction().commit();
>                 registry.cleanupThread();
>                 registry.shutdown();
>         }

> could it work like that or is there something fundamentally wrong here or missing?

> thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Writing a commandline script that uses IOC+Hibernate

Posted by Ulrich Stärk <ul...@apache.org>.
Don't forget to commit your transactions. But apart from that this should work.

Uli

On 28.03.2011 11:24, tmarx78@gmx.de wrote:
> hello everyone!
> 
> i am trying to write a script that will use tapestry-hibernate to will do some database processing tasks from a command line. It also needs to access IOC Services:
> 
> 
> public static void main(String[] args) {
> 		RegistryBuilder builder = new RegistryBuilder();
> 		builder.add(HibernateCoreModule.class);
> 
> 		Registry registry = builder.build();
> 		registry.performRegistryStartup();
> 
> 		HibernateSessionSource hello = registry
> 				.getService(HibernateSessionSource.class);
> 		Session session = hello.getSessionFactory().openSession();
> 		
> 		Something something = new Something();
> 		something.setName("test");
> 
> 		session.persist(type);
> 		registry.cleanupThread();
> 		registry.shutdown();
> 	}
> 
> could it work like that or is there something fundamentally wrong here or missing?
> 
> thanks!
> 
> tobias
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org