Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo]Problem Persisting GMF diagram to HibernateResource
[Teneo]Problem Persisting GMF diagram to HibernateResource [message #604836] Wed, 18 April 2007 08:44
Eclipse UserFriend
Originally posted by:

Hello Martin

I'm having some trouble to use the Teneo HibernateResource (Teneo 0.8.0)
with my GMF diagram (GMF 2.0). I have a model similar to the Mindmap model.
When I start up a new diagram Teneo creates the database tables (if not yet
created) as well as the first root object (Environment) in a Derby database.
I also can save the diagram objects (Nodes) into the diagram file and the
database. When I reopen the diagram_file, the previously saved objects are
loaded from the database and I can add new nodes, and change the node names
(but only on the graphic node, the properties view is not editable!). I can
delete a node in the diagram but it doesn't get deleted in the database (no
exceptions thrown).
Initially I had problems to load the diagram at all, getting the
IllegalStateException: Cannot modify resource set without a write
transaction when saving the root object to the database. This problem was
handled by adding "&DISABLE_NOTIFY=true" to the HibernateResource url, as
described on the site.

There are however still three issues that I'm not getting right:

1) The properties in the property view are not editable (if I use a model
file as originally generated by gmfgen they are editable)

2) When I add a connection between two nodes and try to save, I get
following exception: java.lang.IllegalStateException: Cannot modify resource
set without a write transaction
(See also attached: gmf_diagram.log)

3) Delete is not carried out on the database

After I had generated the diagram code I tried to follow the guideline on It seems that the
generated classes has changed since the guideline was written so I tried to
get it right as good as possible (apparently not good enough though. ;o). I
introduced the following changes in the generated code:


* @generated NOT
public void addPages() {
diagramModelFilePage = new NodeprojectdataCreationWizardPage(
"DiagramModelFile", getSelection(), "amset_diagram");
//$NON-NLS-1$ //$NON-NLS-2$
diagramModelFilePage.setTitle("Create Nodeprojectdata Diagram");
.setDescription("Select file that will contain diagram

// @@@ commented out start
// domainModelFilePage = new
// "DomainModelFile", getSelection(), "amset");
//$NON-NLS-1$ //$NON-NLS-2$
// domainModelFilePage.setTitle("Create Nodeprojectdata
// domainModelFilePage
// .setDescription("Select file that will contain
domain model.");
// addPage(domainModelFilePage);
// @@@ commented out end

* @generated NOT
public boolean performFinish() {
IRunnableWithProgress op = new IRunnableWithProgress() {

public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {

// @@@ added start
String uriStr =
" hibernate://?dsname=amset&DISABLE_NOTIFY=true&query3 =FROM Environment;
URI modelURI = URI.createURI(uriStr);
// @@@ added end

// @@@ changed start
// diagram = NodeprojectdataDiagramEditorUtil.createDiagram(
// diagramModelFilePage.getURI(),
// .getURI(), monitor);
diagram = NodeprojectdataDiagramEditorUtil.createDiagram(
diagramModelFilePage.getURI(), modelURI, monitor);
// @@@ changed end

if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
try {

} catch (PartInitException e) {
"Error opening diagram editor", null, e
try {
getContainer().run(false, true, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof CoreException) {
"Creation Problems", null, ((CoreException) e
} else {
"Error creating diagram", e.getTargetException());
return false;
return diagram != null;


* @generated NOT
public static Resource createDiagram(
org.eclipse.emf.common.util.URI diagramURI,
org.eclipse.emf.common.util.URI modelURI,
IProgressMonitor progressMonitor) {
TransactionalEditingDomain editingDomain =
progressMonitor.beginTask("Creating diagram and model files", 3);
final Resource diagramResource = editingDomain.getResourceSet()
final Resource modelResource = editingDomain.getResourceSet()

final String diagramName = diagramURI.lastSegment();
AbstractTransactionalCommand command = new
"Creating diagram and model", Collections.EMPTY_LIST) {
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
Environment model = createInitialModel();
attachModelToResource(model, modelResource);

Diagram diagram = ViewService

NodeprojectdataDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT) ;
if (diagram != null) {

try {
Map options = new HashMap();
options.put(XMIResource.OPTION_ENCODING, "UTF-8");

// @@@ changed start
//;; <--- This is the
// @@@ changed end;
} catch (IOException e) {

"Unable to store model and diagram resources",
e); //$NON-NLS-1$
return CommandResult.newOKCommandResult();
try {
OperationHistoryFactory.getOperationHistory().execute(comman d,
new SubProgressMonitor(progressMonitor, 1), null);
} catch (ExecutionException e) {
"Unable to create model and diagram", e); //$NON-NLS-1$
return diagramResource;


* @generated NOT
protected void doSaveDocument(IProgressMonitor monitor, Object element,
IDocument document, boolean overwrite) throws CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
if (!overwrite && !info.isSynchronized()) {
throw new CoreException(new Status(IStatus.ERROR,
NodeprojectdataDiagramEditorPlugin.ID, IStatus.OK,
"The file has been changed on the file system",
null)); //$NON-NLS-1$
List resources = info.getResourceSet().getResources();
try {
monitor.beginTask("Saving diagram", resources.size() + 1);
Map options = new HashMap();
for (Iterator it = resources.iterator(); it.hasNext();) {
Resource nextResource = (Resource);
monitor.setTaskName("Saving " + nextResource.getURI());
if (nextResource.isLoaded()
&& (!nextResource.isTrackingModification() ||
.isModified())) {
try {
// @@@ changed start
if (nextResource instanceof HibernateResource) {;
} else {;
// @@@ changed end
} catch (IOException e) {
throw new CoreException(new
EditorStatusCodes.RESOURCE_FAILURE, e
.getLocalizedMessage(), null));
} catch (RuntimeException x) {
throw x;

I would very much appreciate to get your input to those problems. It is
quite a complex issue and I'm not sure if I'm missing something obvious.

Previous Topic:[Teneo]Cannot create mappings for emf's XMLNamespace model
Next Topic:Re: [Validation] ConstraintProvider extension point
Goto Forum:

Current Time: Mon Jan 18 08:44:14 GMT 2021

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

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

Back to the top