Skip to content

Instantly share code, notes, and snippets.

/**
* 指定したModelが、指定したModelの配下にあるのかどうかを返す。
* <p>Modelの構造の外で解決した方が良い気がするので、ここに置いてみた。</p>
* <p>FIXME こんな適当な実装だとメソッドの中がエライ事になりそうだし、この実装はない。なんかうまい実装は無いものか。</p>
*
* @param parent
* @param child
* @return Model同士が親子関係にある時は{@code true}
*/
public static boolean isChild(JiemamyElement parent, JiemamyElement child) {
/**
* TODO for shin1ogawa
*
* @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス)
* @param nodeAdapter ノードに対応する{@link NodeAdapter}
* @param nodeProfile 追加する{@link NodeProfile}
*/
public void addNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter, final NodeProfile nodeProfile) {
DiagramPresentations diagramPresentations = getRootModel().getAdapter(DiagramPresentations.class);
final DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(diagramIndex);
/*
* Copyright 2007-2009 Jiemamy Project and the Others.
* Created on 2008/09/25
*
* This file is part of Jiemamy.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
/*
* Copyright 2007-2009 Jiemamy Project and the Others.
* Created on 2008/09/26
*
* This file is part of Jiemamy.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
[INFO] [datanucleus:enhance {execution: default}]
[INFO] DataNucleus Enhancer (version 1.1.2) : Enhancement of classes
DataNucleus Enhancer : Classpath
>> /Users/shin1/Documents/projects.gae/gae-jdo-simple-sample/target/classes
>> /Users/shin1/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
>> /Users/shin1/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar
>> /Users/shin1/.m2/repository/javax/jdo/jdo2-api/2.3-SNAPSHOT/jdo2-api-2.3-SNAPSHOT.jar
>> /Users/shin1/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
>> /Users/shin1/.m2/repository/com/google/appengine/appengine-api/1.0-sdk-1.2.0/appengine-api-1.0-sdk-1.2.0.jar
>> /Users/shin1/.m2/repository/org/datanucleus/datanucleus-core/1.1.2/datanucleus-core-1.1.2.jar
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shin1ogawa</groupId>
<artifactId>gae-jdo-simple-sample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GAE JDO Simple Sample</name>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>
import java.util.ArrayList;
import java.util.List;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import java.util.ArrayList;
import java.util.List;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
Transaction transaction = pm.currentTransaction();
try {
transaction.begin();
Parent2 target = (Parent2) pm.getObjectById(Parent2.class,
parent.getKey());
pm.deletePersistent(target);
transaction.commit();
} finally {
if (transaction.isActive()) {
transaction.rollback();
javax.jdo.JDOFatalUserException: Attempt was made to modify the primary key of an object of type com.shin1ogawa.entity.Child2 identified by key Parent2(1)/Child2(2). Primary keys are immutable.
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:406)
at org.datanucleus.jdo.JDOPersistenceManager.jdoDeletePersistent(JDOPersistenceManager.java:758)
at org.datanucleus.jdo.JDOPersistenceManager.deletePersistent(JDOPersistenceManager.java:771)
at com.shin1ogawa.OwnedRelationshipUsingEncodedStringTest.親エンティティを削除(OwnedRelationshipUsingEncodedStringTest.java:84)
...