You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ravi Puri <ra...@gmail.com> on 2016/04/22 12:22:43 UTC

At client side unable to use excute transaction?

server side
----------
at server side i loaded my data with person and also configured with my
database..

cache.loadCache(null,100_000);
cache.size();// It returns length of cache.

client side
----------
public static void main (String args[])
	{
		Ignition.setClientMode(true);
		Ignite ignite=Ignition.start("ignite-example.xml");
		
		
		IgniteCache<String, SessionManagementVO> cache =
ignite.getOrCreateCache("CacheName");
		System.out.println(cache.size());// it also succesfully returns same
length 

		executeTransaction(cache);// but her it shows error
	}
	private static void executeTransaction(IgniteCache<String, Person> cache) {
        try (Transaction tx = Ignition.ignite().transactions().txStart()) {
        	Person val = cache.get(2);// here it show error.

             System.out.println("Read value: " + val);

            
             tx.commit();
        }  
    }

the error is:


Exception in thread "main" org.hibernate.LazyInitializationException: could
not initialize proxy - no Session
	at
org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:186)
	at
org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:545)
	at
org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:124)
	at
org.hibernate.collection.internal.PersistentMap.toString(PersistentMap.java:270)
	at java.lang.String.valueOf(Unknown Source)
	at java.lang.StringBuilder.append(Unknown Source)
	at com.tcs.utility.vo.DeviceVO.toString(DeviceVO.java:139)
	at java.lang.String.valueOf(Unknown Source)
	at java.lang.StringBuilder.append(Unknown Source)
	at com.tcs.vo.SessionManagementVO.toString(SessionManagementVO.java:171)
	at java.lang.String.valueOf(Unknown Source)
	at java.lang.StringBuilder.append(Unknown Source)
	at com.demo.ClientSide.executeTransaction(ClientSide.java:29)
	at com.demo.ClientSide.main(ClientSide.java:23)




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/At-client-side-unable-to-use-excute-transaction-tp4447.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: At client side unable to use excute transaction?

Posted by Alexey Goncharuk <al...@gmail.com>.
Ravi,

It's been a while since I used Hibernate last time, but as far as I
remember, you may do either:
 * call any method (e.g. size()) on your proxied collection to trigger lazy
collection initialization
 * Call Hibernate.initialize(collectionProxy)
 * Use @ManyToOne(fetch = FetchType.EAGER) in your relation definition

You should consult Hibernate documentation chapter regarding lazy
collection initialization and proxies.
​
Hope this helps,
Alexey

Re: At client side unable to use excute transaction?

Posted by Ravi kumar Puri <ra...@gmail.com>.
How to materialize it?
On 23-Apr-2016 02:53, "Alexey Goncharuk" <al...@gmail.com> wrote:

> Val,
>
> StringBuilder.append() is what javac generates for `"Read value: " + val`
> in the code.
>
> Ravi,
>
> Hibernate returned you a collection proxy for your map, however by the
> time control flow leaves the CacheStore your hibernate session gets closed
> and this collection proxy cannot be used anymore. You need to make sure
> that all objects (and fields in those objects) returned from the cache
> store get materialized before the session is closed.
>

Re: At client side unable to use excute transaction?

Posted by Alexey Goncharuk <al...@gmail.com>.
Val,

StringBuilder.append() is what javac generates for `"Read value: " + val`
in the code.

Ravi,

Hibernate returned you a collection proxy for your map, however by the time
control flow leaves the CacheStore your hibernate session gets closed and
this collection proxy cannot be used anymore. You need to make sure that
all objects (and fields in those objects) returned from the cache store get
materialized before the session is closed.

Re: At client side unable to use excute transaction?

Posted by vkulichenko <va...@gmail.com>.
Hi Ravi,

I'm confused by the trace. It shows that executeTransaction() method called
StringBuilder.append(), but I don't see this in the code you provided. Is it
the full trace? If so, are you sure that you properly rebuild the project?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/At-client-side-unable-to-use-excute-transaction-tp4447p4468.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.