Pages

Showing posts with label collection. Show all posts
Showing posts with label collection. Show all posts

Sunday, April 19, 2020

ERROR : DefaultDispatcherErrorHandler Exception occurred during processing request: failed to lazily initialize a collection of role,could not initialize proxy - no Session

ERROR : DefaultDispatcherErrorHandler Exception occurred during processing request: failed to lazily initialize a collection of role: com.javaimplant.socialnetwork.model.User.friend, could not initialize proxy - no Session
 org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.javaimplant.socialnetwork.model.User.friend, could not initialize proxy - no Session


I got this error while trying to map a One to Many relation in my Hibernate Entity.
The issue can be resolved by adding the following fetch property above our Entity Property.

 @OneToMany(fetch = FetchType.EAGER)  
      private Set<User> friend;  



Thursday, February 10, 2011

Items collection must be empty before using ItemsSource.

This error occurs when you try to add Children to a control which already has a item source as a result there is a lot of confusion to the parser regarding which one to choose.

Any children you add to the control are a part of its item collection consider for example

<listview margin="8,9,11,125" name="listView1" itemssource="{Binding}" minwidth="250" minheight="200" columnspan="2" rowspan="2">
<listview.view>
<gridview>
<gridviewcolumn header="ID" displaymemberbinding="{Binding Path=ID}"></gridviewcolumn>
<gridviewcolumn header="Company" displaymemberbinding="{Binding Path=Company}"></gridviewcolumn>
<gridviewcolumn header="Email" displaymemberbinding="{Binding Path=Email}"></gridviewcolumn>
<gridviewcolumn header="Website" displaymemberbinding="{Binding Path=Website}"></gridviewcolumn>
<gridviewcolumn header="Phone" displaymemberbinding="{Binding Path=Phone}"></gridviewcolumn>
<gridviewcolumn header="Address" displaymemberbinding="{Binding Path=Address}"></gridviewcolumn>
<gridviewcolumn header="Field of Development" displaymemberbinding="{Binding Path=Field}"></gridviewcolumn>
<gridviewcolumn header="Notes" displaymemberbinding="{Binding Path=Notes}"></gridviewcolumn>
</gridview>
</listview.view>
<Button Margin="0,0,-326.634,-49.995" Name="buttonReset" HorizontalAlignment="Right" Grid.Row="6" Width="99.99" Height="31.123" VerticalAlignment="Bottom" Click="buttonReset_Click">Reset</Button>
</listview>

Now here I have added a button in the last as a part of Item collection for the list view so it gives me that error

When I remove that code everything works fine.We cannot insert items and set items source at same time.