Workaround for Hibernate relationships and SmartGWT RESTDataSources

I'm lost with the way I have to implement a ManyToMany relationship defined in Hibernate. In the client-side we're using SmartGWT LGPL version with RESTDataSources working fine against some back-end webservices.

The relationship is made between a typical Role and Permissions. In Rol.class:

...
@ManyToMany
@JoinTable(name = "ROL_PERMISO", joinColumns = @JoinColumn(name = "ROL_ID"), inverseJoinColumns = @JoinColumn(name = "PERMISO_ID"))
private Set<Permiso> permisos;
...

In the client side I have two 'views'. The first one is for permission's management. The another one is for role management, which has a ListGrid showing roles and a DynamicForm with a permissions CheckBoxTree to select the permissions associated to the role, and other fields like name and description.

How I stablish the relationship between roles and permissions in the DataSources? Any recommended workaround?

Answers


After searching on it I've solved that using nested DataSource:

In Rol DataSource:

...
// One to Many relationship
DataSourceField permisos = new DataSourceField("permisos", FieldType.TEXT, locale.permisos());
permisos.setTypeAsDataSource(PermisoDS.getInstance());
...

The key is create a DatSourceField and set the type as DataSource. And then, for accessing the data you can use getAttributeAsRecordArray("permisos") in a record of Rol DataSource

Hope this help someone!


Need Your Help

A whole storm of unknown errors while rebooting my Sharepoint Server 2010?

sql-server sharepoint visual-studio-2010 iis-7 sharepoint-2010

Okay, these are the errors I can't backtrace at all. So I was hoping you had any idea.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.