Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » swt emf hibernate databinding
swt emf hibernate databinding [message #660223] Thu, 17 March 2011 13:05 Go to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 61
Registered: February 2011
Member
Hello all. Can anybody tell me, we a i can read about emf datamodel databinding to swt components(TableViewer). My datamodel works through hibernate with mysql database.
private static HbDataStore dataStore;
static {
		try {
			String dataStoreName = "WtpDataStore";
			dataStore = HbHelper.INSTANCE
					.createRegisterDataStore(dataStoreName);
			dataStore.setEPackages(new EPackage[] { WtpdbPackage.eINSTANCE });
			dataStore.initialize();
			sessionFactory = dataStore.getSessionFactory();
		} catch (Throwable ex) {
			System.err.println("Initial SessionFactory creation failed" + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

Re: swt emf hibernate databinding [message #660255 is a reply to message #660223] Thu, 17 March 2011 15:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Alex,

Googling "emf databinding table" turns up quite a few things. Certainly
all the documentation I'm aware of, like Tom's and Lars' blogs.


Alex wrote:
> Hello all. Can anybody tell me, we a i can read about emf datamodel
> databinding to swt components(TableViewer). My datamodel works through
> hibernate with mysql database.
>
> private static HbDataStore dataStore;
> static {
> try {
> String dataStoreName = "WtpDataStore";
> dataStore = HbHelper.INSTANCE
> .createRegisterDataStore(dataStoreName);
> dataStore.setEPackages(new EPackage[] {
> WtpdbPackage.eINSTANCE });
> dataStore.initialize();
> sessionFactory = dataStore.getSessionFactory();
> } catch (Throwable ex) {
> System.err.println("Initial SessionFactory creation
> failed" + ex);
> throw new ExceptionInInitializerError(ex);
> }
> }
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: swt emf hibernate databinding [message #660377 is a reply to message #660255] Fri, 18 March 2011 08:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Like Ed already mentionned in my blog is a lot of informations about
EMF-Databinding [1].

The complete source code from my example is found in EMF-CVS. The code
you present only shows how you create the session factory. Are you
afterwards executing HQL-Queries?

I hope I can find the time to write up how we've architecture our
applications who make heavy use of EMF (Core+Edit), EMF-Databinding and
Teneo.

Tom

[1]http://tomsondev.bestsolution.at/

Am 17.03.11 16:00, schrieb Ed Merks:
> Alex,
>
> Googling "emf databinding table" turns up quite a few things. Certainly
> all the documentation I'm aware of, like Tom's and Lars' blogs.
>
>
> Alex wrote:
>> Hello all. Can anybody tell me, we a i can read about emf datamodel
>> databinding to swt components(TableViewer). My datamodel works through
>> hibernate with mysql database.
>>
>> private static HbDataStore dataStore;
>> static {
>> try {
>> String dataStoreName = "WtpDataStore";
>> dataStore = HbHelper.INSTANCE
>> .createRegisterDataStore(dataStoreName);
>> dataStore.setEPackages(new EPackage[] {
>> WtpdbPackage.eINSTANCE });
>> dataStore.initialize();
>> sessionFactory = dataStore.getSessionFactory();
>> } catch (Throwable ex) {
>> System.err.println("Initial SessionFactory creation
>> failed" + ex);
>> throw new ExceptionInInitializerError(ex);
>> }
>> }
>>
>>
Re: swt emf hibernate databinding [message #660561 is a reply to message #660223] Sat, 19 March 2011 13:24 Go to previous messageGo to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 61
Registered: February 2011
Member
Well, i have created this stuff:
@Override
	public void createPartControl(final Composite parent) {
groupViewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION
				| SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		Session session = HibernateFactory.currentSession();
		session.beginTransaction();
		Query query = session.createQuery("from p6group");
		List<p6group> groups = query.list();
		HibernateFactory.commit(session.getTransaction());
		HibernateFactory.closeSession();
		createColumns(parent,groupViewer);
		final Table table = groupViewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		groupViewer.setContentProvider(new ArrayContentProvider());
		groupViewer.setInput(groups);
		getSite().setSelectionProvider(groupViewer);
		GridData gridData = new GridData();
		gridData.verticalAlignment = GridData.FILL;
		gridData.horizontalSpan = 2;
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		groupViewer.getControl().setLayoutData(gridData);
		
}

Is this a good approach for jface databinding with emf, teneo, hibernate?
Re: swt emf hibernate databinding [message #660569 is a reply to message #660561] Sat, 19 March 2011 14:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

a) You are not useing any Databinding stuff in your code but pure JFace-
Viewer API

b) You might get into problems with lazy loading because you load the
list and close the session afterwards => if you are accessing stuff
not yet loaded you'll get an exception

Tom

Am 19.03.11 06:24, schrieb Alex:
> Well, i have created this stuff:
>
> @Override
> public void createPartControl(final Composite parent) {
> groupViewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION
> | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
> Session session = HibernateFactory.currentSession();
> session.beginTransaction();
> Query query = session.createQuery("from p6group");
> List<p6group> groups = query.list();
> HibernateFactory.commit(session.getTransaction());
> HibernateFactory.closeSession();
> createColumns(parent,groupViewer);
> final Table table = groupViewer.getTable();
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
> groupViewer.setContentProvider(new ArrayContentProvider());
> groupViewer.setInput(groups);
> getSite().setSelectionProvider(groupViewer);
> GridData gridData = new GridData();
> gridData.verticalAlignment = GridData.FILL;
> gridData.horizontalSpan = 2;
> gridData.grabExcessHorizontalSpace = true;
> gridData.grabExcessVerticalSpace = true;
> gridData.horizontalAlignment = GridData.FILL;
> groupViewer.getControl().setLayoutData(gridData);
>
> }
>
> Is this a good approach for jface databinding with emf, teneo, hibernate?
Re: swt emf hibernate databinding [message #660577 is a reply to message #660569] Sat, 19 March 2011 15:33 Go to previous messageGo to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 61
Registered: February 2011
Member
Tom, thank you for your help, but can you give me some example, how i can load data from db to emf model?
Re: swt emf hibernate databinding [message #660584 is a reply to message #660577] Sat, 19 March 2011 16:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010605050406040702020202
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Alex,

You'll probably want to have a look at Teneo:

http://www.eclipse.org/modeling/emft/?project=teneo


Alex wrote:
> Tom, thank you for your help, but can you give me some example, how i
> can load data from db to emf model?
>

--------------010605050406040702020202
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alex,<br>
<br>
You'll probably want to have a look at Teneo:<br>
<blockquote><a
href="http://www.eclipse.org/modeling/emft/?project=teneo">http://www.eclipse.org/modeling/emft/?project=teneo</a><br>
</blockquote>
<br>
Alex wrote:
<blockquote cite="mid:im2hus$1rd$1@news.eclipse.org" type="cite">Tom,
thank you for your help, but can you give me some example, how i can
load data from db to emf model?
<br>
<br>
</blockquote>
</body>
</html>

--------------010605050406040702020202--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: swt emf hibernate databinding [message #660592 is a reply to message #660577] Sat, 19 March 2011 17:10 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alex,
This direct linke to the docs should help:
http://wiki.eclipse.org/Teneo/Hibernate

gr. Martin

On 03/19/2011 04:33 PM, Alex wrote:
> Tom, thank you for your help, but can you give me some example, how i can load data from db to emf model?
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:EAnnotation serialization
Next Topic:EMF code-generation in maven builds?
Goto Forum:
  


Current Time: Thu Mar 28 12:37:37 GMT 2024

Powered by FUDForum. Page generated in 0.02619 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top