Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1d4d9a26385ab842ea697f32c7ec1aca725ce747 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Martin Taal - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.hibernate;

import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.legacy.Model1Package;
import org.eclipse.emf.cdo.transaction.CDOTransaction;

import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EcoreFactory;

/**
 * @author Martin Taal
 */
public class HibernateBugzilla_373545_Test extends AbstractCDOTest
{
  public void testSetId() throws Exception
  {
    // add the id and generated value annotations
    final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
    eAnnotation.setSource("teneo.jpa");
    eAnnotation.getDetails().put("value", "@Id @GeneratedValue(generator=\"system-uuid\")");
    Model1Package.eINSTANCE.getCategory_Name().getEAnnotations().add(eAnnotation);

    Category category1;
    {
      final CDOSession session = openSession();
      final CDOTransaction transaction = session.openTransaction();

      final CDOResource resource = transaction.createResource(getResourcePath("/test1"));
      category1 = getModel1Factory().createCategory();
      resource.getContents().add(category1);

      transaction.commit();
    }
    {
      final CDOSession session = openSession();
      final CDOTransaction transaction = session.openTransaction();
      final CDOResource resource = transaction.getResource(getResourcePath("/test1"));
      final Category category2 = (Category)resource.getContents().get(0);
      assertNotSame(category1, category2);
      System.err.println(((CDOObject)category2).cdoID());
      assertNotNull(category2.getName());
      transaction.commit();
    }
  }
}

Back to the top