2 | Package providing components specific to JDO persistence.
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | formatter_profile=_DataNucleus Conventions
3 | formatter_settings_version=12
4 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/state/package.html:
--------------------------------------------------------------------------------
1 |
2 | Definition of lifecycle states when providing JDO persistence
3 |
4 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/package.html:
--------------------------------------------------------------------------------
1 |
2 | Package containing exceptions thrown that are specific to JDO persistence
3 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/inmemory/package.html:
--------------------------------------------------------------------------------
1 |
2 | Package providing DataNucleus handling for in-memory JDOQL querying.
3 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/package.html:
--------------------------------------------------------------------------------
1 |
2 | Package providing DataNucleus' implementation of the JDOQL standardised typed query.
3 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/package.html:
--------------------------------------------------------------------------------
1 |
2 | Package providing DataNucleus extension annotations providing features not in the JDO spec.
3 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/api/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Package providing implementation classes for the JDO Metadata API.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/package.html:
--------------------------------------------------------------------------------
1 |
2 | Package providing DataNucleus' implementation of the JDOQL standardised typed query for geospatial types.
3 |
--------------------------------------------------------------------------------
/src/main/resources/org/datanucleus/api/jdo/Localisation_es.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datanucleus/datanucleus-api-jdo/HEAD/src/main/resources/org/datanucleus/api/jdo/Localisation_es.properties
--------------------------------------------------------------------------------
/src/main/resources/META-INF/README.txt:
--------------------------------------------------------------------------------
1 | DataNucleus-API-JDO
2 | ===================
3 | This project provides support for the JDO API.
4 |
5 | This project is licensed by the Apache 2 license which you should have received with this.
6 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Package providing classes specific to processing of JDO XML MetaData and annotations, building on
4 | the generic code under the package org.datanucleus.metadata
5 |
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Feature Request: provide as much detail as possible about behaviour
2 | ## Bug Report, attach a testcase using [problem guide](http://www.datanucleus.org/documentation/problem_reporting.html) and state what version the problem occurs in. Any "Bug" without a testcase will be CLOSED.
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/main/resources/META-INF=UTF-8
5 | encoding//src/test=UTF-8
6 | encoding//src/test/java=UTF-8
7 | encoding//src/test/resources=UTF-8
8 | encoding/=UTF-8
9 |
--------------------------------------------------------------------------------
/src/test/resources/org/datanucleus/api/jdo/metadata/xml/package1.jdo:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/test/resources/org/datanucleus/api/jdo/metadata/xml/package2.jdo:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/org/datanucleus/api/jdo/metadata/xml/persistence1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/resources/org/datanucleus/api/jdo/metadata/xml/persistence2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/NOTICE.txt:
--------------------------------------------------------------------------------
1 | =========================================================================
2 | == NOTICE file corresponding to section 4(d) of the Apache License, ==
3 | == Version 2.0, in this case for the DataNucleus distribution. ==
4 | =========================================================================
5 |
6 | ===================================================================
7 | This product includes software developed by many individuals,
8 | including the following:
9 | ===================================================================
10 | Erik Bengtson
11 | Andy Jefferson
12 |
13 |
14 | ===================================================================
15 | This product has included contributions from some individuals,
16 | including the following:
17 | ===================================================================
18 |
19 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/ExpressionType.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | /**
21 | * Type of typesafe expression.
22 | */
23 | public enum ExpressionType
24 | {
25 | PATH,
26 | PARAMETER,
27 | VARIABLE
28 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/JDOPropertyNames.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo;
19 |
20 | /**
21 | * Utility providing convenience naming of JDO persistence properties.
22 | */
23 | public class JDOPropertyNames
24 | {
25 | public static final String PROPERTY_METADATA_XML_JDO_1_0 = "datanucleus.metadata.xml.allowJDO1_0".toLowerCase();
26 | }
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | datanucleus-api-jdo
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jem.workbench.JavaEMFNature
31 | org.eclipse.wst.common.modulecore.ModuleCoreNature
32 | org.eclipse.pde.PluginNature
33 | org.eclipse.m2e.core.maven2Nature
34 | org.eclipse.jdt.core.javanature
35 | org.eclipse.wst.common.project.facet.core.nature
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/ReadOnly.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation allowing for specifying a field as Read-Only (insertable=false, updateable=false) or for specifying a class as Read-Only.
27 | */
28 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
29 | @Retention(RetentionPolicy.RUNTIME)
30 | public @interface ReadOnly
31 | {
32 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/JDOClassNameConstants.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo;
19 |
20 | import javax.jdo.PersistenceManagerFactory;
21 |
22 | /**
23 | * Class providing names of common JDO classes to aid performance.
24 | */
25 | public class JDOClassNameConstants
26 | {
27 | /** javax.jdo.PersistenceManagerFactory **/
28 | public static final String JAVAX_JDO_PersistenceManagerFactory = PersistenceManagerFactory.class.getName();
29 |
30 | /** org.datanucleus.api.jdo.JDOPersistenceManagerFactory **/
31 | public static final String JDOPersistenceManagerFactory = JDOPersistenceManagerFactory.class.getName();
32 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/api/FieldMetadataImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2009 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.metadata.api;
19 |
20 | import javax.jdo.metadata.FieldMetadata;
21 |
22 | import org.datanucleus.metadata.FetchGroupMemberMetaData;
23 | import org.datanucleus.metadata.FieldMetaData;
24 |
25 | /**
26 | * Implementation of JDO FieldMetadata object.
27 | */
28 | public class FieldMetadataImpl extends MemberMetadataImpl implements FieldMetadata
29 | {
30 | public FieldMetadataImpl(FieldMetaData internal)
31 | {
32 | super(internal);
33 | }
34 |
35 | public FieldMetadataImpl(FetchGroupMemberMetaData internal)
36 | {
37 | super(internal);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/ComparatorClass.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation providing for specifying a comparator class against a collection.
27 | */
28 | @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD})
29 | @Retention(RetentionPolicy.RUNTIME)
30 | public @interface ComparatorClass
31 | {
32 | /**
33 | * The class of the comparator
34 | * @return comparator class
35 | */
36 | Class value();
37 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/api/InterfaceMetadataImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2009 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.metadata.api;
19 |
20 | import javax.jdo.metadata.InterfaceMetadata;
21 |
22 | import org.datanucleus.metadata.InterfaceMetaData;
23 |
24 | /**
25 | * Implementation of JDO InterfaceMetadata object.
26 | */
27 | public class InterfaceMetadataImpl extends TypeMetadataImpl implements InterfaceMetadata
28 | {
29 | public InterfaceMetadataImpl(InterfaceMetaData internal)
30 | {
31 | super(internal);
32 | }
33 |
34 | public AbstractMetadataImpl getParent()
35 | {
36 | if (parent == null)
37 | {
38 | parent = new PackageMetadataImpl(((InterfaceMetaData)internalMD).getPackageMetaData());
39 | }
40 | return super.getParent();
41 | }
42 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/ByteExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import javax.jdo.query.ByteExpression;
21 | import javax.jdo.query.PersistableExpression;
22 |
23 | import org.datanucleus.store.query.expression.Expression;
24 |
25 | /**
26 | * Implementation of a ByteExpression
27 | */
28 | public class ByteExpressionImpl extends ComparableExpressionImpl implements ByteExpression
29 | {
30 | public ByteExpressionImpl(PersistableExpression parent, String name)
31 | {
32 | super(parent, name);
33 | }
34 |
35 | public ByteExpressionImpl(Class cls, String name, ExpressionType type)
36 | {
37 | super(cls, name, type);
38 | }
39 |
40 | public ByteExpressionImpl(Expression queryExpr)
41 | {
42 | super(queryExpr);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/NoPersistenceInformationException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.exceptions;
19 |
20 | import javax.jdo.JDOUserException;
21 |
22 | /**
23 | * Exception thrown when a class is required to have persistence information (metadata/annotations) yet none can be found.
24 | */
25 | public class NoPersistenceInformationException extends JDOUserException
26 | {
27 | private static final long serialVersionUID = 8218822469557539549L;
28 |
29 | /**
30 | * Constructs an exception for the specified class with the supplied nested exception.
31 | * @param msg The message
32 | * @param nested the nested exception(s).
33 | */
34 | public NoPersistenceInformationException(String msg, Exception nested)
35 | {
36 | super(msg, nested);
37 | }
38 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/ObjectExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import javax.jdo.query.ObjectExpression;
21 | import javax.jdo.query.PersistableExpression;
22 |
23 | import org.datanucleus.store.query.expression.Expression;
24 |
25 | /**
26 | * Implementation of an expression for all unsupported types.
27 | */
28 | public class ObjectExpressionImpl extends ExpressionImpl implements ObjectExpression
29 | {
30 | public ObjectExpressionImpl(PersistableExpression parent, String name)
31 | {
32 | super(parent, name);
33 | }
34 |
35 | public ObjectExpressionImpl(Class cls, String name, ExpressionType type)
36 | {
37 | super(cls, name, type);
38 | }
39 |
40 | public ObjectExpressionImpl(Expression queryExpr)
41 | {
42 | super(queryExpr);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/TransactionActiveException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | 2002 Kelly Grizzle (TJDO)
18 | 2003 Andy Jefferson - commented and localised.
19 | ...
20 | **********************************************************************/
21 | package org.datanucleus.api.jdo.exceptions;
22 |
23 | import javax.jdo.JDOUserException;
24 |
25 | import org.datanucleus.util.Localiser;
26 |
27 | /**
28 | * An TransactionActiveException is thrown if a transaction is already active and an operation is performed that requires that a transaction not be
29 | * active (such as beginning a transaction).
30 | */
31 | public class TransactionActiveException extends JDOUserException
32 | {
33 | private static final long serialVersionUID = 6273891154508609229L;
34 |
35 | public TransactionActiveException(Object failedObject)
36 | {
37 | super(Localiser.msg("015032"),failedObject);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/TransactionCommitingException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | 2002 Kelly Grizzle (TJDO)
18 | 2003 Andy Jefferson - commented and localised.
19 | ...
20 | **********************************************************************/
21 | package org.datanucleus.api.jdo.exceptions;
22 |
23 | import javax.jdo.JDOUserException;
24 |
25 | import org.datanucleus.util.Localiser;
26 |
27 | /**
28 | * A TransactionCommitingException is thrown if a transaction is committing or rolling back and an operation is performed that changes the transaction state or
29 | * behaviour (such as beginning setRetainValues).
30 | */
31 | public class TransactionCommitingException extends JDOUserException
32 | {
33 | private static final long serialVersionUID = -1805767358303642401L;
34 |
35 | public TransactionCommitingException(Object failedObject)
36 | {
37 | super(Localiser.msg("015036"),failedObject);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/UpdateTimestamp.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation specifying either this field/method or use a surrogate column as storing the update timestamp for this object.
27 | * Only applies if specified on a timestamp.
28 | */
29 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
30 | @Retention(RetentionPolicy.RUNTIME)
31 | public @interface UpdateTimestamp
32 | {
33 | /**
34 | * Name of the update timestamp column in the table for this class when this is a surrogate (class-level) column.
35 | * @return The update timestamp column name
36 | */
37 | String column() default "UPDATE_TIMESTAMP";
38 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/ComparatorClassHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import org.datanucleus.ClassLoaderResolver;
21 | import org.datanucleus.metadata.AbstractMemberMetaData;
22 | import org.datanucleus.metadata.MetaData;
23 | import org.datanucleus.metadata.annotations.AnnotationObject;
24 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
25 |
26 | /**
27 | * Handler for the {@link ComparatorClass} annotation when applied to a collection field/property of a persistable class.
28 | */
29 | public class ComparatorClassHandler implements MemberAnnotationHandler
30 | {
31 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
32 | {
33 | Class value = (Class)ann.getNameValueMap().get("value");
34 |
35 | mmd.addExtension(MetaData.EXTENSION_MEMBER_COMPARATOR_NAME, value.getName());
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/CreateTimestamp.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation specifying either this field/method or use a surrogate column as storing the creation timestamp for this object.
27 | * Only applies if specified on a timestamp.
28 | */
29 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
30 | @Retention(RetentionPolicy.RUNTIME)
31 | public @interface CreateTimestamp
32 | {
33 | /**
34 | * Name of the create timestamp column in the table for this class when this is a surrogate (class-level) column.
35 | * @return The create timestamp column name
36 | */
37 | String column() default "CREATE_TIMESTAMP";
38 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/ConnectionInUseException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | 2002 Kelly Grizzle (TJDO)
18 | 2003 Andy Jefferson - commented and localised.
19 | ...
20 | **********************************************************************/
21 | package org.datanucleus.api.jdo.exceptions;
22 |
23 | import javax.jdo.JDOUserException;
24 |
25 | import org.datanucleus.util.Localiser;
26 |
27 | /**
28 | * An ConnectionInUseException is thrown if an operation is attempted that requires a new database connection (such as Transaction.begin()) and a
29 | * previously obtained database connection (such as for non-transactional read or write) is still in-use.
30 | */
31 | public class ConnectionInUseException extends JDOUserException
32 | {
33 | private static final long serialVersionUID = -7180648507612667518L;
34 |
35 | /**
36 | * Constructor.
37 | */
38 | public ConnectionInUseException()
39 | {
40 | super(Localiser.msg("009003"));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/MultiPointExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.PersistableExpression;
21 | import javax.jdo.query.geospatial.MultiPointExpression;
22 |
23 | import org.datanucleus.api.jdo.query.ExpressionType;
24 | import org.datanucleus.store.query.expression.Expression;
25 |
26 | /**
27 | * Implementation of a MultiPointExpression.
28 | */
29 | public class MultiPointExpressionImpl extends GeometryCollectionExpressionImpl implements MultiPointExpression
30 | {
31 | public MultiPointExpressionImpl(PersistableExpression parent, String name)
32 | {
33 | super(parent, name);
34 | }
35 |
36 | public MultiPointExpressionImpl(Expression queryExpr)
37 | {
38 | super(queryExpr);
39 | }
40 |
41 | public MultiPointExpressionImpl(Class cls, String name, ExpressionType type)
42 | {
43 | super(cls, name, type);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/MultiPolygonExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.PersistableExpression;
21 | import javax.jdo.query.geospatial.MultiPolygonExpression;
22 |
23 | import org.datanucleus.api.jdo.query.ExpressionType;
24 | import org.datanucleus.store.query.expression.Expression;
25 |
26 | /**
27 | * Implementation of a MultiPolygonExpression.
28 | */
29 | public class MultiPolygonExpressionImpl extends GeometryCollectionExpressionImpl implements MultiPolygonExpression
30 | {
31 | public MultiPolygonExpressionImpl(PersistableExpression parent, String name)
32 | {
33 | super(parent, name);
34 | }
35 |
36 | public MultiPolygonExpressionImpl(Expression queryExpr)
37 | {
38 | super(queryExpr);
39 | }
40 |
41 | public MultiPolygonExpressionImpl(Class cls, String name, ExpressionType type)
42 | {
43 | super(cls, name, type);
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/GeometryCollectionExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.PersistableExpression;
21 | import javax.jdo.query.geospatial.GeometryCollectionExpression;
22 |
23 | import org.datanucleus.api.jdo.query.ExpressionType;
24 | import org.datanucleus.store.query.expression.Expression;
25 |
26 | /**
27 | * Implementation of a GeometryCollectionExpression.
28 | */
29 | public class GeometryCollectionExpressionImpl extends GeometryExpressionImpl implements GeometryCollectionExpression
30 | {
31 | public GeometryCollectionExpressionImpl(PersistableExpression parent, String name)
32 | {
33 | super(parent, name);
34 | }
35 |
36 | public GeometryCollectionExpressionImpl(Expression queryExpr)
37 | {
38 | super(queryExpr);
39 | }
40 |
41 | public GeometryCollectionExpressionImpl(Class cls, String name, ExpressionType type)
42 | {
43 | super(cls, name, type);
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/TransactionNotReadableException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2008 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.exceptions;
19 |
20 | import org.datanucleus.util.Localiser;
21 |
22 | /**
23 | * A TransactionNotReadableException is thrown if an operation needs either of an active transaction or non-transactional read and neither is true.
24 | */
25 | public class TransactionNotReadableException extends TransactionNotActiveException
26 | {
27 | private static final long serialVersionUID = 2573953722247061663L;
28 |
29 | /**
30 | * Constructor.
31 | */
32 | public TransactionNotReadableException()
33 | {
34 | super(Localiser.msg("015041"), null);
35 | }
36 |
37 | /**
38 | * Constructor.
39 | * @param message the localized error message
40 | * @param failedObject the failed object
41 | */
42 | public TransactionNotReadableException(String message, Object failedObject)
43 | {
44 | super(message,failedObject);
45 | }
46 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/TransactionNotWritableException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2008 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.exceptions;
19 |
20 | import org.datanucleus.util.Localiser;
21 |
22 | /**
23 | * A TransactionNotReadableException is thrown if an operation needs either of an active transaction or non-transactional read and neither is true.
24 | */
25 | public class TransactionNotWritableException extends TransactionNotActiveException
26 | {
27 | private static final long serialVersionUID = -8641406435403033411L;
28 |
29 | /**
30 | * Constructor.
31 | */
32 | public TransactionNotWritableException()
33 | {
34 | super(Localiser.msg("015041"), null);
35 | }
36 |
37 | /**
38 | * Constructor.
39 | * @param message the localized error message
40 | * @param failedObject the failed object
41 | */
42 | public TransactionNotWritableException(String message, Object failedObject)
43 | {
44 | super(message, failedObject);
45 | }
46 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/UpdateUser.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation specifying either this field/method or use a surrogate column as storing the update user for this object.
27 | * Only applies if specified on a String.
28 | */
29 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
30 | @Retention(RetentionPolicy.RUNTIME)
31 | public @interface UpdateUser
32 | {
33 | /**
34 | * Name of the update user column in the table for this class when this is a surrogate (class-level) column.
35 | * @return The update user column name
36 | */
37 | String column() default "UPDATE_USER";
38 |
39 | /**
40 | * Length of the update user column.
41 | * @return Length of the update user column.
42 | */
43 | int columnLength() default -1;
44 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/CreateUser.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation specifying either this field/method or use a surrogate column as storing the creation user for this object.
27 | * Only applies if specified on a String.
28 | */
29 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
30 | @Retention(RetentionPolicy.RUNTIME)
31 | public @interface CreateUser
32 | {
33 | /**
34 | * Name of the create user column in the table for this class when this is a surrogate (class-level) column.
35 | * @return The create user column name
36 | */
37 | String column() default "CREATE_USER";
38 |
39 | /**
40 | * Length of the create user column.
41 | * @return Length of the create user column.
42 | */
43 | int columnLength() default -1;
44 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/state/DetachedDirty.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | ...
18 | **********************************************************************/
19 | package org.datanucleus.api.jdo.state;
20 |
21 | import org.datanucleus.state.LifeCycleState;
22 | import org.datanucleus.state.DNStateManager;
23 |
24 | /**
25 | * Class representing the life cycle state of DetachedDirty.
26 | */
27 | class DetachedDirty extends LifeCycleState
28 | {
29 | /** Protected Constructor to prevent external instantiation. */
30 | protected DetachedDirty()
31 | {
32 | isPersistent = false;
33 | isDirty = true;
34 | isNew = false;
35 | isDeleted = false;
36 | isTransactional = false;
37 |
38 | stateType = DETACHED_DIRTY;
39 | }
40 |
41 | /**
42 | * Method to return a string version of this object.
43 | * @return The string "DETACHED_DIRTY".
44 | **/
45 | public String toString()
46 | {
47 | return "DETACHED_DIRTY";
48 | }
49 |
50 | @Override
51 | public LifeCycleState transitionAttach(DNStateManager sm)
52 | {
53 | return changeState(sm, P_DIRTY);
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/api/ExtensionMetadataImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2009 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.metadata.api;
19 |
20 | import javax.jdo.metadata.ExtensionMetadata;
21 |
22 | /**
23 | * Implementation of JDO ExtensionMetadata object.
24 | */
25 | public class ExtensionMetadataImpl implements ExtensionMetadata
26 | {
27 | String vendor;
28 | String key;
29 | String value;
30 |
31 | public ExtensionMetadataImpl(String vendor, String key, String value)
32 | {
33 | this.vendor = vendor;
34 | this.key = key;
35 | this.value = value;
36 | }
37 |
38 | /* (non-Javadoc)
39 | * @see javax.jdo.metadata.ExtensionMetadata#getKey()
40 | */
41 | public String getKey()
42 | {
43 | return key;
44 | }
45 |
46 | /* (non-Javadoc)
47 | * @see javax.jdo.metadata.ExtensionMetadata#getValue()
48 | */
49 | public String getValue()
50 | {
51 | return value;
52 | }
53 |
54 | /* (non-Javadoc)
55 | * @see javax.jdo.metadata.ExtensionMetadata#getVendorName()
56 | */
57 | public String getVendorName()
58 | {
59 | return vendor;
60 | }
61 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/SharedRelation.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Extension annotation providing for marking a relation as "shared" and adding a distinguisher column.
27 | */
28 | @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD})
29 | @Retention(RetentionPolicy.RUNTIME)
30 | public @interface SharedRelation
31 | {
32 | /**
33 | * The name of the distinguisher column.
34 | * @return The column name
35 | */
36 | String column();
37 |
38 | /**
39 | * Whether the distinguisher column defaults to being part of the PK (false unless specified).
40 | * @return Whether part of the PK
41 | */
42 | boolean primaryKey() default false;
43 |
44 | /**
45 | * The value to be stored in the distinguisher column for this relation.
46 | * @return distinguishing value
47 | */
48 | String value();
49 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/state/DetachedClean.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | 2005 Andy Jefferson - split into own file
18 | ...
19 | **********************************************************************/
20 | package org.datanucleus.api.jdo.state;
21 |
22 | import org.datanucleus.state.LifeCycleState;
23 | import org.datanucleus.state.DNStateManager;
24 |
25 | /**
26 | * Class representing the life cycle state of DetachedClean.
27 | */
28 | class DetachedClean extends LifeCycleState
29 | {
30 | /** Protected Constructor to prevent external instantiation. */
31 | protected DetachedClean()
32 | {
33 | isPersistent = false;
34 | isDirty = false;
35 | isNew = false;
36 | isDeleted = false;
37 | isTransactional = false;
38 |
39 | stateType = DETACHED_CLEAN;
40 | }
41 |
42 | /**
43 | * Method to return a string version of this object.
44 | * @return The string "DETACHED_CLEAN".
45 | **/
46 | public String toString()
47 | {
48 | return "DETACHED_CLEAN";
49 | }
50 |
51 | @Override
52 | public LifeCycleState transitionAttach(DNStateManager sm)
53 | {
54 | return changeState(sm, P_CLEAN);
55 | }
56 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/TransactionNotActiveException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | 2002 Kelly Grizzle (TJDO)
18 | 2003 Andy Jefferson - commented and localised.
19 | ...
20 | **********************************************************************/
21 | package org.datanucleus.api.jdo.exceptions;
22 |
23 | import javax.jdo.JDOUserException;
24 |
25 | import org.datanucleus.util.Localiser;
26 |
27 | /**
28 | * A TransactionNotActiveException is thrown if a transaction is not active and an operation is performed that requires that a transaction be
29 | * active (such as committing a transaction).
30 | */
31 | public class TransactionNotActiveException extends JDOUserException
32 | {
33 | private static final long serialVersionUID = -5645432840786957250L;
34 |
35 | /**
36 | * Constructor.
37 | */
38 | public TransactionNotActiveException()
39 | {
40 | super(Localiser.msg("015035"));
41 | }
42 |
43 | /**
44 | * Constructor.
45 | * @param message the localized error message
46 | * @param failedObject the failed object
47 | */
48 | public TransactionNotActiveException(String message, Object failedObject)
49 | {
50 | super(message,failedObject);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/MultiTenant.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | import javax.jdo.annotations.Column;
26 |
27 | /**
28 | * Extension annotation allowing for specifying a class as multitenant, meaning that it will have a surrogate column in its table storing the tenant id.
29 | */
30 | @Target({ElementType.TYPE})
31 | @Retention(RetentionPolicy.RUNTIME)
32 | public @interface MultiTenant
33 | {
34 | /**
35 | * Name of the multitenancy column in the table for this class.
36 | * @return The multitenancy column name
37 | */
38 | String column() default "TENANT_ID";
39 |
40 | /**
41 | * The column making up the multitenancy discriminator.
42 | * @return the column making up the multitenancy discriminator
43 | */
44 | Column[] columns() default {};
45 |
46 | /**
47 | * Whether the multitenancy discriminator is indexed.
48 | * @return whether the multitenancy discriminator is indexed
49 | */
50 | String indexed() default "";
51 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/SoftDelete.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | import javax.jdo.annotations.Column;
26 |
27 | /**
28 | * Extension annotation allowing for specifying a class as using soft delete, meaning that it will have a surrogate column in its table storing
29 | * whether it is deleted (rather than deleting it).
30 | */
31 | @Target({ElementType.TYPE})
32 | @Retention(RetentionPolicy.RUNTIME)
33 | public @interface SoftDelete
34 | {
35 | /**
36 | * Name of the soft delete flag column in the table for this class.
37 | * @return The soft delete column name
38 | */
39 | String column() default "DELETED";
40 |
41 | /**
42 | * The column making up the soft delete indicator.
43 | * @return the column making up the soft delete indicator.
44 | */
45 | Column[] columns() default {};
46 |
47 | /**
48 | * Whether the soft delete column is indexed.
49 | * @return whether the soft delete column is indexed
50 | */
51 | String indexed() default "";
52 | }
--------------------------------------------------------------------------------
/src/main/resources/org/datanucleus/api/jdo/jdoquery_3_2.dtd:
--------------------------------------------------------------------------------
1 |
17 |
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 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/metadata/api/PropertyMetadataImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2009 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.metadata.api;
19 |
20 | import javax.jdo.metadata.PropertyMetadata;
21 |
22 | import org.datanucleus.metadata.FetchGroupMemberMetaData;
23 | import org.datanucleus.metadata.PropertyMetaData;
24 |
25 | /**
26 | * Implementation of JDO PropertyMetadata object.
27 | */
28 | public class PropertyMetadataImpl extends MemberMetadataImpl implements PropertyMetadata
29 | {
30 | public PropertyMetadataImpl(PropertyMetaData internal)
31 | {
32 | super(internal);
33 | }
34 |
35 | public PropertyMetadataImpl(FetchGroupMemberMetaData internal)
36 | {
37 | super(internal);
38 | }
39 |
40 | public PropertyMetaData getInternal()
41 | {
42 | return (PropertyMetaData)internalMD;
43 | }
44 |
45 | /* (non-Javadoc)
46 | * @see javax.jdo.metadata.PropertyMetadata#getFieldName()
47 | */
48 | public String getFieldName()
49 | {
50 | return getInternal().getFieldName();
51 | }
52 |
53 | /* (non-Javadoc)
54 | * @see javax.jdo.metadata.PropertyMetadata#setFieldName(java.lang.String)
55 | */
56 | public PropertyMetadata setFieldName(String name)
57 | {
58 | getInternal().setFieldName(name);
59 | return this;
60 | }
61 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/FieldInstanceLifecycleEvent.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo;
19 |
20 | import javax.jdo.listener.InstanceLifecycleEvent;
21 |
22 | /**
23 | * Extension to InstanceLifecycleEvent where the event can relate to specific
24 | * field providing access to the field names that are affected by this event.
25 | */
26 | public class FieldInstanceLifecycleEvent extends InstanceLifecycleEvent
27 | {
28 | private static final long serialVersionUID = 4518746566556032678L;
29 | /** Names of the fields affected. */
30 | private String[] fieldNames;
31 |
32 | /**
33 | * Constructor.
34 | * @param obj The object on which the event occurs
35 | * @param eventType Type of event
36 | * @param otherObj The other object
37 | * @param fieldNames Names of the fields affected
38 | */
39 | public FieldInstanceLifecycleEvent(Object obj, int eventType, Object otherObj, String[] fieldNames)
40 | {
41 | super(obj, eventType, otherObj);
42 | this.fieldNames = fieldNames;
43 | }
44 |
45 | /**
46 | * Accessor for the field names affected by this event
47 | * @return The field names
48 | */
49 | public String[] getFieldNames()
50 | {
51 | return fieldNames;
52 | }
53 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/EnumExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import javax.jdo.query.EnumExpression;
21 | import javax.jdo.query.NumericExpression;
22 | import javax.jdo.query.PersistableExpression;
23 |
24 | import org.datanucleus.store.query.expression.Expression;
25 | import org.datanucleus.store.query.expression.InvokeExpression;
26 |
27 | /**
28 | * Implementation of an Enum expression.
29 | */
30 | public class EnumExpressionImpl extends ComparableExpressionImpl implements EnumExpression
31 | {
32 | public EnumExpressionImpl(PersistableExpression parent, String name)
33 | {
34 | super(parent, name);
35 | }
36 |
37 | public EnumExpressionImpl(Class cls, String name, ExpressionType type)
38 | {
39 | super(cls, name, type);
40 | }
41 |
42 | public EnumExpressionImpl(Expression queryExpr)
43 | {
44 | super(queryExpr);
45 | }
46 |
47 | /* (non-Javadoc)
48 | * @see org.datanucleus.query.typesafe.EnumExpression#ordinal()
49 | */
50 | public NumericExpression ordinal()
51 | {
52 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "ordinal", null);
53 | return new NumericExpressionImpl(invokeExpr);
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/SharedRelationHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.util.Map;
21 |
22 | import org.datanucleus.ClassLoaderResolver;
23 | import org.datanucleus.metadata.AbstractMemberMetaData;
24 | import org.datanucleus.metadata.MetaData;
25 | import org.datanucleus.metadata.annotations.AnnotationObject;
26 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
27 |
28 | /**
29 | * Handler for the {@link SharedRelation} annotation when applied to a field/property of a persistable class.
30 | */
31 | public class SharedRelationHandler implements MemberAnnotationHandler
32 | {
33 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
34 | {
35 | Map annotationValues = ann.getNameValueMap();
36 | String column = (String)annotationValues.get("column");
37 | String value = (String)annotationValues.get("value");
38 | Boolean pk = (Boolean)annotationValues.get("primaryKey");
39 |
40 | mmd.addExtension(MetaData.EXTENSION_MEMBER_RELATION_DISCRIM_COLUMN, column);
41 | mmd.addExtension(MetaData.EXTENSION_MEMBER_RELATION_DISCRIM_VALUE, value);
42 | if (pk)
43 | {
44 | mmd.addExtension(MetaData.EXTENSION_MEMBER_RELATION_DISCRIM_PK, "true");
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/exceptions/ClassNotPersistenceCapableException.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | 2002 Kelly Grizzle (TJDO)
17 | 2003 Andy Jefferson - commented and localised.
18 | 2004 Andy Jefferson - changed to take the class name.
19 | ...
20 | **********************************************************************/
21 | package org.datanucleus.api.jdo.exceptions;
22 |
23 | import javax.jdo.JDOUserException;
24 |
25 | /**
26 | * A ClassNotPersistenceCapableException is thrown if an attempt is made to persist an object whose class is not persistence-capable.
27 | * This may be because the class has not been appropriately enhanced to be made persistence-capable.
28 | */
29 | public class ClassNotPersistenceCapableException extends JDOUserException
30 | {
31 | private static final long serialVersionUID = -32361409923511910L;
32 |
33 | /**
34 | * Constructs a class-not-persistence-capable exception with the specified detail message.
35 | * @param msg The message
36 | */
37 | public ClassNotPersistenceCapableException(String msg)
38 | {
39 | super(msg);
40 | }
41 |
42 | /**
43 | * Constructs a class-not-persistence-capable exception with the specified
44 | * detail message and nested exception.
45 | * @param msg The message
46 | * @param nested the nested exception(s).
47 | */
48 | public ClassNotPersistenceCapableException(String msg, Exception nested)
49 | {
50 | super(msg, nested);
51 | }
52 | }
--------------------------------------------------------------------------------
/src/test/java/org/datanucleus/api/jdo/metadata/xml/JDOXmlMetaDataHandlerTest.java:
--------------------------------------------------------------------------------
1 | /******************************************************************
2 | Copyright (c) 2007 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | ...
18 | *****************************************************************/
19 | package org.datanucleus.api.jdo.metadata.xml;
20 |
21 | import junit.framework.TestCase;
22 |
23 | import org.datanucleus.NucleusContext;
24 | import org.datanucleus.PersistenceNucleusContextImpl;
25 | import org.datanucleus.api.jdo.metadata.JDOMetaDataManager;
26 | import org.datanucleus.metadata.MetaData;
27 | import org.datanucleus.metadata.xml.XmlMetaDataParser;
28 |
29 | public class JDOXmlMetaDataHandlerTest extends TestCase
30 | {
31 | public void testParseDefaultNamespace()
32 | {
33 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
34 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
35 | MetaData md = parser.parseXmlMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package1.jdo"), "jdo");
36 | assertNotNull(md);
37 | }
38 |
39 | public void testParseNamespace()
40 | {
41 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
42 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
43 | MetaData md = parser.parseXmlMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package2.jdo"), "jdo");
44 | assertNotNull(md);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/org/datanucleus/api/jdo/metadata/xml/PersistenceFileMetaDataHandlerTest.java:
--------------------------------------------------------------------------------
1 | /******************************************************************
2 | Copyright (c) 2007 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | ...
18 | *****************************************************************/
19 | package org.datanucleus.api.jdo.metadata.xml;
20 |
21 | import junit.framework.TestCase;
22 |
23 | import org.datanucleus.NucleusContext;
24 | import org.datanucleus.PersistenceNucleusContextImpl;
25 | import org.datanucleus.api.jdo.metadata.JDOMetaDataManager;
26 | import org.datanucleus.metadata.MetaData;
27 | import org.datanucleus.metadata.xml.XmlMetaDataParser;
28 |
29 | public class PersistenceFileMetaDataHandlerTest extends TestCase
30 | {
31 | public void testParseDefaultNamespace()
32 | {
33 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
34 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
35 | MetaData md = parser.parseXmlMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/persistence1.xml"), "persistence");
36 | assertNotNull(md);
37 | }
38 |
39 | public void testParseNamespace()
40 | {
41 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
42 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
43 | MetaData md = parser.parseXmlMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/persistence2.xml"), "persistence");
44 | assertNotNull(md);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/UpdateTimestampHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.util.Map;
21 |
22 | import org.datanucleus.ClassLoaderResolver;
23 | import org.datanucleus.metadata.AbstractClassMetaData;
24 | import org.datanucleus.metadata.AbstractMemberMetaData;
25 | import org.datanucleus.metadata.MetaData;
26 | import org.datanucleus.metadata.annotations.AnnotationObject;
27 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
28 |
29 | /**
30 | * Handler for the {@link UpdateTimestamp} annotation when applied to a field/property or surrogate column of a persistable class.
31 | */
32 | public class UpdateTimestampHandler implements MemberAnnotationHandler
33 | {
34 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
35 | {
36 | mmd.addExtension(MetaData.EXTENSION_MEMBER_UPDATE_TIMESTAMP, "true");
37 | }
38 |
39 | public void processClassAnnotation(AnnotationObject annotation, AbstractClassMetaData cmd, ClassLoaderResolver clr)
40 | {
41 | cmd.addExtension(MetaData.EXTENSION_CLASS_UPDATETIMESTAMP, "true");
42 |
43 | Map annotationValues = annotation.getNameValueMap();
44 | String column = (String)annotationValues.get("column");
45 | if (column != null && column.length() > 0)
46 | {
47 | cmd.addExtension(MetaData.EXTENSION_CLASS_UPDATETIMESTAMP_COLUMN_NAME, column);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/LinearRingExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.BooleanExpression;
21 | import javax.jdo.query.PersistableExpression;
22 | import javax.jdo.query.geospatial.LinearRingExpression;
23 |
24 | import org.datanucleus.api.jdo.query.BooleanExpressionImpl;
25 | import org.datanucleus.api.jdo.query.ExpressionType;
26 | import org.datanucleus.store.query.expression.Expression;
27 | import org.datanucleus.store.query.expression.InvokeExpression;
28 |
29 | /**
30 | * Implementation of a LinearRingExpression.
31 | */
32 | public class LinearRingExpressionImpl extends GeometryExpressionImpl implements LinearRingExpression
33 | {
34 | public LinearRingExpressionImpl(PersistableExpression parent, String name)
35 | {
36 | super(parent, name);
37 | }
38 |
39 | public LinearRingExpressionImpl(Expression queryExpr)
40 | {
41 | super(queryExpr);
42 | }
43 |
44 | public LinearRingExpressionImpl(Class cls, String name, ExpressionType type)
45 | {
46 | super(cls, name, type);
47 | }
48 |
49 | /* (non-Javadoc)
50 | * @see javax.jdo.query.geospatial.LinearRingExpression#isClosed()
51 | */
52 | @Override
53 | public BooleanExpression isClosed()
54 | {
55 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "isClosed", null);
56 | return new BooleanExpressionImpl(invokeExpr);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/MultiLineStringExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.BooleanExpression;
21 | import javax.jdo.query.PersistableExpression;
22 | import javax.jdo.query.geospatial.MultiLineStringExpression;
23 |
24 | import org.datanucleus.api.jdo.query.BooleanExpressionImpl;
25 | import org.datanucleus.api.jdo.query.ExpressionType;
26 | import org.datanucleus.store.query.expression.Expression;
27 | import org.datanucleus.store.query.expression.InvokeExpression;
28 |
29 | /**
30 | * Implementation of a MultiLineStringExpression.
31 | */
32 | public class MultiLineStringExpressionImpl extends GeometryCollectionExpressionImpl implements MultiLineStringExpression
33 | {
34 | public MultiLineStringExpressionImpl(PersistableExpression parent, String name)
35 | {
36 | super(parent, name);
37 | }
38 |
39 | public MultiLineStringExpressionImpl(Expression queryExpr)
40 | {
41 | super(queryExpr);
42 | }
43 |
44 | public MultiLineStringExpressionImpl(Class cls, String name, ExpressionType type)
45 | {
46 | super(cls, name, type);
47 | }
48 |
49 | /* (non-Javadoc)
50 | * @see javax.jdo.query.geospatial.LinearRingExpression#isClosed()
51 | */
52 | @Override
53 | public BooleanExpression isClosed()
54 | {
55 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "isClosed", null);
56 | return new BooleanExpressionImpl(invokeExpr);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/ReadOnlyHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import org.datanucleus.ClassLoaderResolver;
21 | import org.datanucleus.metadata.AbstractClassMetaData;
22 | import org.datanucleus.metadata.AbstractMemberMetaData;
23 | import org.datanucleus.metadata.MetaData;
24 | import org.datanucleus.metadata.annotations.AnnotationObject;
25 | import org.datanucleus.metadata.annotations.ClassAnnotationHandler;
26 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
27 |
28 | /**
29 | * Handler for the {@link ReadOnly} annotation when applied to a field/property of a persistable class, or when applied to a class itself.
30 | */
31 | public class ReadOnlyHandler implements MemberAnnotationHandler, ClassAnnotationHandler
32 | {
33 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
34 | {
35 | mmd.addExtension(MetaData.EXTENSION_MEMBER_INSERTABLE, "false");
36 | mmd.addExtension(MetaData.EXTENSION_MEMBER_UPDATEABLE, "false");
37 | }
38 |
39 | /* (non-Javadoc)
40 | * @see org.datanucleus.metadata.annotations.ClassAnnotationHandler#processClassAnnotation(org.datanucleus.metadata.annotations.AnnotationObject, org.datanucleus.metadata.AbstractClassMetaData, org.datanucleus.ClassLoaderResolver)
41 | */
42 | @Override
43 | public void processClassAnnotation(AnnotationObject annotation, AbstractClassMetaData cmd, ClassLoaderResolver clr)
44 | {
45 | cmd.addExtension(MetaData.EXTENSION_CLASS_READ_ONLY, "true");
46 | }
47 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/CreateTimestampHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2016 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.util.Map;
21 |
22 | import org.datanucleus.ClassLoaderResolver;
23 | import org.datanucleus.metadata.AbstractClassMetaData;
24 | import org.datanucleus.metadata.AbstractMemberMetaData;
25 | import org.datanucleus.metadata.MetaData;
26 | import org.datanucleus.metadata.annotations.AnnotationObject;
27 | import org.datanucleus.metadata.annotations.ClassAnnotationHandler;
28 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
29 |
30 | /**
31 | * Handler for the {@link CreateTimestamp} annotation when applied to a field/property or surrogate column of a persistable class.
32 | */
33 | public class CreateTimestampHandler implements MemberAnnotationHandler, ClassAnnotationHandler
34 | {
35 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
36 | {
37 | mmd.addExtension(MetaData.EXTENSION_MEMBER_CREATE_TIMESTAMP, "true");
38 | }
39 |
40 | public void processClassAnnotation(AnnotationObject annotation, AbstractClassMetaData cmd, ClassLoaderResolver clr)
41 | {
42 | cmd.addExtension(MetaData.EXTENSION_CLASS_CREATETIMESTAMP, "true");
43 |
44 | Map annotationValues = annotation.getNameValueMap();
45 | String column = (String)annotationValues.get("column");
46 | if (column != null && column.length() > 0)
47 | {
48 | cmd.addExtension(MetaData.EXTENSION_CLASS_CREATETIMESTAMP_COLUMN_NAME, column);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/OrderExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import javax.jdo.query.Expression;
21 | import javax.jdo.query.OrderExpression;
22 |
23 | /**
24 | * Implementation of an ordering expression.
25 | */
26 | public class OrderExpressionImpl implements OrderExpression
27 | {
28 | /** The ordering expression. */
29 | protected Expression orderExpr;
30 |
31 | /** The order direction for this expression. */
32 | protected OrderDirection direction;
33 |
34 | /** Positioning of nulls in the ordering. */
35 | protected OrderNullsPosition nullsPosition;
36 |
37 | public OrderExpressionImpl(Expression expr, OrderDirection dir)
38 | {
39 | this.orderExpr = expr;
40 | this.direction = dir;
41 | }
42 |
43 | /* (non-Javadoc)
44 | * @see org.datanucleus.query.typesafe.OrderExpression#getDirection()
45 | */
46 | public OrderExpression.OrderDirection getDirection()
47 | {
48 | return direction;
49 | }
50 |
51 | /* (non-Javadoc)
52 | * @see org.datanucleus.query.typesafe.OrderExpression#getExpression()
53 | */
54 | public Expression getExpression()
55 | {
56 | return orderExpr;
57 | }
58 |
59 | public OrderNullsPosition getNullsPosition()
60 | {
61 | return nullsPosition;
62 | }
63 |
64 | public OrderExpression nullsFirst()
65 | {
66 | this.nullsPosition = OrderNullsPosition.FIRST;
67 | return this;
68 | }
69 |
70 | public OrderExpression nullsLast()
71 | {
72 | this.nullsPosition = OrderNullsPosition.LAST;
73 | return this;
74 | }
75 | }
--------------------------------------------------------------------------------
/src/test/java/org/datanucleus/api/jdo/metadata/xml/XmlMetaDataParserTest.java:
--------------------------------------------------------------------------------
1 | /******************************************************************
2 | Copyright (c) 2007 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | ...
18 | *****************************************************************/
19 | package org.datanucleus.api.jdo.metadata.xml;
20 |
21 | import junit.framework.TestCase;
22 |
23 | import org.datanucleus.NucleusContext;
24 | import org.datanucleus.PersistenceNucleusContextImpl;
25 | import org.datanucleus.api.jdo.metadata.JDOMetaDataManager;
26 | import org.datanucleus.exceptions.NucleusException;
27 | import org.datanucleus.metadata.xml.XmlMetaDataParser;
28 |
29 | public class XmlMetaDataParserTest extends TestCase
30 | {
31 | public void testParseMetaDataURLnullURL()
32 | {
33 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
34 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
35 | try
36 | {
37 | parser.parseXmlMetaDataURL(null, "jdo");
38 | fail("expected NucleusException");
39 | }
40 | catch(NucleusException ex)
41 | {
42 | //expected
43 | }
44 | }
45 |
46 | public void testParseMetaDataURLnullhandler()
47 | {
48 | NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
49 | XmlMetaDataParser parser = new XmlMetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
50 | try
51 | {
52 | parser.parseXmlMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package2.jdo"), null);
53 | fail("expected NucleusException");
54 | }
55 | catch(NucleusException ex)
56 | {
57 | //expected
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/state/LifeCycleStateFactory.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Contributors:
17 | ...
18 | **********************************************************************/
19 | package org.datanucleus.api.jdo.state;
20 |
21 | import org.datanucleus.state.LifeCycleState;
22 |
23 | /**
24 | * Factory for life cycle states.
25 | */
26 | public abstract class LifeCycleStateFactory
27 | {
28 | private static LifeCycleState states[];
29 |
30 | static
31 | {
32 | states = new LifeCycleState[LifeCycleState.TOTAL];
33 |
34 | states[LifeCycleState.HOLLOW] = new Hollow();
35 | states[LifeCycleState.P_CLEAN] = new PersistentClean();
36 | states[LifeCycleState.P_DIRTY] = new PersistentDirty();
37 | states[LifeCycleState.P_NEW] = new PersistentNew();
38 | states[LifeCycleState.P_NEW_DELETED] = new PersistentNewDeleted();
39 | states[LifeCycleState.P_DELETED] = new PersistentDeleted();
40 | states[LifeCycleState.P_NONTRANS] = new PersistentNontransactional();
41 | states[LifeCycleState.T_CLEAN] = new TransientClean();
42 | states[LifeCycleState.T_DIRTY] = new TransientDirty();
43 | states[LifeCycleState.P_NONTRANS_DIRTY] = new PersistentNontransactionalDirty();
44 | states[LifeCycleState.DETACHED_CLEAN] = new DetachedClean();
45 | states[LifeCycleState.DETACHED_DIRTY] = new DetachedDirty();
46 | states[LifeCycleState.TRANSIENT] = null;
47 | }
48 |
49 | /**
50 | * Returns the LifeCycleState for the state constant.
51 | * @param stateType the type as integer
52 | * @return the type as LifeCycleState object
53 | */
54 | public static final LifeCycleState getLifeCycleState(int stateType)
55 | {
56 | return states[stateType];
57 | }
58 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/JDOTypeConverter.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2015 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo;
19 |
20 | import javax.jdo.AttributeConverter;
21 |
22 | import org.datanucleus.store.types.converters.TypeConverter;
23 |
24 | /**
25 | * Wrapper for a JDO AttributeConverter for use internally to DataNucleus.
26 | * @param Member type for this converter
27 | * @param Datastore type for storing this member with this converter
28 | */
29 | public class JDOTypeConverter implements TypeConverter
30 | {
31 | private static final long serialVersionUID = -4250901331525617340L;
32 |
33 | AttributeConverter jdoConverter;
34 |
35 | /**
36 | * Constructor for a JDO type converter, wrapping a javax.jdo.AttributeConverter.
37 | * @param conv The JDO AttributeConverter
38 | */
39 | public JDOTypeConverter(AttributeConverter conv)
40 | {
41 | this.jdoConverter = conv;
42 | }
43 |
44 | /* (non-Javadoc)
45 | * @see org.datanucleus.store.types.converters.TypeConverter#toDatastoreType(java.lang.Object)
46 | */
47 | @Override
48 | public Y toDatastoreType(X memberValue)
49 | {
50 | return jdoConverter.convertToDatastore(memberValue);
51 | }
52 |
53 | /* (non-Javadoc)
54 | * @see org.datanucleus.store.types.converters.TypeConverter#toMemberType(java.lang.Object)
55 | */
56 | @Override
57 | public X toMemberType(Y datastoreValue)
58 | {
59 | return jdoConverter.convertToAttribute(datastoreValue);
60 | }
61 |
62 | public AttributeConverter getAttributeConverter()
63 | {
64 | return jdoConverter;
65 | }
66 |
67 | public String toString()
68 | {
69 | return "JDOTypeConverter for " + jdoConverter;
70 | }
71 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/CreateUserHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.util.Map;
21 |
22 | import org.datanucleus.ClassLoaderResolver;
23 | import org.datanucleus.metadata.AbstractClassMetaData;
24 | import org.datanucleus.metadata.AbstractMemberMetaData;
25 | import org.datanucleus.metadata.MetaData;
26 | import org.datanucleus.metadata.annotations.AnnotationObject;
27 | import org.datanucleus.metadata.annotations.ClassAnnotationHandler;
28 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
29 |
30 | /**
31 | * Handler for the {@link CreateUser} annotation when applied to a field/property or surrogate column of a persistable class.
32 | */
33 | public class CreateUserHandler implements MemberAnnotationHandler, ClassAnnotationHandler
34 | {
35 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
36 | {
37 | mmd.addExtension(MetaData.EXTENSION_MEMBER_CREATE_USER, "true");
38 | }
39 |
40 | public void processClassAnnotation(AnnotationObject annotation, AbstractClassMetaData cmd, ClassLoaderResolver clr)
41 | {
42 | cmd.addExtension(MetaData.EXTENSION_CLASS_CREATEUSER, "true");
43 |
44 | Map annotationValues = annotation.getNameValueMap();
45 | String colName = (String)annotationValues.get("column");
46 | if (colName != null && colName.length() > 0)
47 | {
48 | cmd.addExtension(MetaData.EXTENSION_CLASS_CREATEUSER_COLUMN_NAME, colName);
49 | }
50 |
51 | Integer colLength = (Integer)annotationValues.get("columnLength");
52 | if (colLength != null && colLength > 0)
53 | {
54 | cmd.addExtension(MetaData.EXTENSION_CLASS_CREATEUSER_COLUMN_LENGTH, "" + colLength);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/annotations/UpdateUserHandler.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2017 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.annotations;
19 |
20 | import java.util.Map;
21 |
22 | import org.datanucleus.ClassLoaderResolver;
23 | import org.datanucleus.metadata.AbstractClassMetaData;
24 | import org.datanucleus.metadata.AbstractMemberMetaData;
25 | import org.datanucleus.metadata.MetaData;
26 | import org.datanucleus.metadata.annotations.AnnotationObject;
27 | import org.datanucleus.metadata.annotations.ClassAnnotationHandler;
28 | import org.datanucleus.metadata.annotations.MemberAnnotationHandler;
29 |
30 | /**
31 | * Handler for the {@link UpdateUser} annotation when applied to a field/property or surrogate column of a persistable class.
32 | */
33 | public class UpdateUserHandler implements MemberAnnotationHandler, ClassAnnotationHandler
34 | {
35 | public void processMemberAnnotation(AnnotationObject ann, AbstractMemberMetaData mmd, ClassLoaderResolver clr)
36 | {
37 | mmd.addExtension(MetaData.EXTENSION_MEMBER_UPDATE_USER, "true");
38 | }
39 |
40 | public void processClassAnnotation(AnnotationObject annotation, AbstractClassMetaData cmd, ClassLoaderResolver clr)
41 | {
42 | cmd.addExtension(MetaData.EXTENSION_CLASS_UPDATEUSER, "true");
43 |
44 | Map annotationValues = annotation.getNameValueMap();
45 | String colName = (String)annotationValues.get("column");
46 | if (colName != null && colName.length() > 0)
47 | {
48 | cmd.addExtension(MetaData.EXTENSION_CLASS_UPDATEUSER_COLUMN_NAME, colName);
49 | }
50 |
51 | Integer colLength = (Integer)annotationValues.get("columnLength");
52 | if (colLength != null && colLength > 0)
53 | {
54 | cmd.addExtension(MetaData.EXTENSION_CLASS_UPDATEUSER_COLUMN_LENGTH, "" + colLength);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/geospatial/PointExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.geospatial;
19 |
20 | import javax.jdo.query.NumericExpression;
21 | import javax.jdo.query.PersistableExpression;
22 | import javax.jdo.query.geospatial.PointExpression;
23 |
24 | import org.datanucleus.api.jdo.query.ExpressionType;
25 | import org.datanucleus.api.jdo.query.NumericExpressionImpl;
26 | import org.datanucleus.store.query.expression.Expression;
27 | import org.datanucleus.store.query.expression.InvokeExpression;
28 |
29 | /**
30 | * Implementation of a PointExpression.
31 | */
32 | public class PointExpressionImpl extends GeometryExpressionImpl implements PointExpression
33 | {
34 | public PointExpressionImpl(PersistableExpression parent, String name)
35 | {
36 | super(parent, name);
37 | }
38 |
39 | public PointExpressionImpl(Expression queryExpr)
40 | {
41 | super(queryExpr);
42 | }
43 |
44 | public PointExpressionImpl(Class cls, String name, ExpressionType type)
45 | {
46 | super(cls, name, type);
47 | }
48 |
49 | /* (non-Javadoc)
50 | * @see javax.jdo.query.geospatial.PointExpression#getX()
51 | */
52 | @Override
53 | public NumericExpression getX()
54 | {
55 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "getX", null);
56 | return new NumericExpressionImpl(invokeExpr);
57 | }
58 |
59 | /* (non-Javadoc)
60 | * @see javax.jdo.query.geospatial.PointExpression#getY()
61 | */
62 | @Override
63 | public NumericExpression getY()
64 | {
65 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "getY", null);
66 | return new NumericExpressionImpl(invokeExpr);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/ListExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | import javax.jdo.query.Expression;
24 | import javax.jdo.query.ListExpression;
25 | import javax.jdo.query.NumericExpression;
26 | import javax.jdo.query.PersistableExpression;
27 |
28 | import org.datanucleus.store.query.expression.InvokeExpression;
29 | import org.datanucleus.store.query.expression.Literal;
30 |
31 | /**
32 | * Implementation of a ListExpression.
33 | */
34 | public class ListExpressionImpl, E> extends CollectionExpressionImpl implements ListExpression
35 | {
36 | public ListExpressionImpl(PersistableExpression parent, String name)
37 | {
38 | super(parent, name);
39 | }
40 |
41 | public ListExpressionImpl(Class cls, String name, ExpressionType type)
42 | {
43 | super(cls, name, type);
44 | }
45 |
46 | /* (non-Javadoc)
47 | * @see org.datanucleus.query.typesafe.ListExpression#get(int)
48 | */
49 | public Expression get(int pos)
50 | {
51 | List args = new ArrayList();
52 | args.add(new Literal(pos));
53 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "get", args);
54 | return new ExpressionImpl(invokeExpr);
55 | }
56 |
57 | /* (non-Javadoc)
58 | * @see org.datanucleus.query.typesafe.ListExpression#get(org.datanucleus.query.typesafe.NumericExpression)
59 | */
60 | public Expression get(NumericExpression posExpr)
61 | {
62 | List args = new ArrayList();
63 | args.add(((ExpressionImpl)posExpr).getQueryExpression());
64 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "get", args);
65 | return new ExpressionImpl(invokeExpr);
66 | }
67 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/inmemory/JDOHelperGetVersionFunction.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2008 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.inmemory;
19 |
20 | import javax.jdo.JDOHelper;
21 |
22 | import org.datanucleus.exceptions.NucleusException;
23 | import org.datanucleus.store.query.QueryUtils;
24 | import org.datanucleus.store.query.expression.Expression;
25 | import org.datanucleus.store.query.expression.InvokeExpression;
26 | import org.datanucleus.store.query.expression.ParameterExpression;
27 | import org.datanucleus.store.query.expression.PrimaryExpression;
28 | import org.datanucleus.store.query.inmemory.InMemoryExpressionEvaluator;
29 | import org.datanucleus.store.query.inmemory.InvocationEvaluator;
30 |
31 | /**
32 | * Evaluator for the function JDOHelper.getVersion(obj).
33 | */
34 | public class JDOHelperGetVersionFunction implements InvocationEvaluator
35 | {
36 | /* (non-Javadoc)
37 | * @see org.datanucleus.query.evaluator.memory.InvocationEvaluator#evaluate(org.datanucleus.query.expression.InvokeExpression, org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator)
38 | */
39 | public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval)
40 | {
41 | Expression argExpr = expr.getArguments().get(0);
42 | if (argExpr instanceof PrimaryExpression)
43 | {
44 | PrimaryExpression primExpr = (PrimaryExpression)argExpr;
45 | Object value = eval.getValueForPrimaryExpression(primExpr);
46 | return JDOHelper.getVersion(value);
47 | }
48 | else if (argExpr instanceof ParameterExpression)
49 | {
50 | ParameterExpression paramExpr = (ParameterExpression)argExpr;
51 | Object value = QueryUtils.getValueForParameterExpression(eval.getParameterValues(), paramExpr);
52 | return JDOHelper.getVersion(value);
53 | }
54 | else
55 | {
56 | throw new NucleusException("Dont currently support JDOHelper.getVersion with arg of type " + argExpr.getClass().getName());
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/inmemory/JDOHelperGetObjectIdFunction.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2008 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query.inmemory;
19 |
20 | import javax.jdo.JDOHelper;
21 |
22 | import org.datanucleus.exceptions.NucleusException;
23 | import org.datanucleus.store.query.QueryUtils;
24 | import org.datanucleus.store.query.expression.Expression;
25 | import org.datanucleus.store.query.expression.InvokeExpression;
26 | import org.datanucleus.store.query.expression.ParameterExpression;
27 | import org.datanucleus.store.query.expression.PrimaryExpression;
28 | import org.datanucleus.store.query.inmemory.InMemoryExpressionEvaluator;
29 | import org.datanucleus.store.query.inmemory.InvocationEvaluator;
30 |
31 | /**
32 | * Evaluator for the function JDOHelper.getObjectId(obj).
33 | */
34 | public class JDOHelperGetObjectIdFunction implements InvocationEvaluator
35 | {
36 | /* (non-Javadoc)
37 | * @see org.datanucleus.query.evaluator.memory.InvocationEvaluator#evaluate(org.datanucleus.query.expression.InvokeExpression, org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator)
38 | */
39 | public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval)
40 | {
41 | Expression argExpr = expr.getArguments().get(0);
42 | if (argExpr instanceof PrimaryExpression)
43 | {
44 | PrimaryExpression primExpr = (PrimaryExpression)argExpr;
45 | Object value = eval.getValueForPrimaryExpression(primExpr);
46 | return JDOHelper.getObjectId(value);
47 | }
48 | else if (argExpr instanceof ParameterExpression)
49 | {
50 | ParameterExpression paramExpr = (ParameterExpression)argExpr;
51 | Object value = QueryUtils.getValueForParameterExpression(eval.getParameterValues(), paramExpr);
52 | return JDOHelper.getObjectId(value);
53 | }
54 | else
55 | {
56 | throw new NucleusException("Dont currently support JDOHelper.getObjectId with arg of type " + argExpr.getClass().getName());
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/state/TransientDirty.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.state;
19 |
20 | import org.datanucleus.state.LifeCycleState;
21 | import org.datanucleus.state.DNStateManager;
22 | import org.datanucleus.transaction.Transaction;
23 |
24 | /**
25 | * Class representing the life cycle state of TransientDirty.
26 | */
27 | class TransientDirty extends LifeCycleState
28 | {
29 | TransientDirty()
30 | {
31 | // these flags are set only in the constructor
32 | // and shouldn't be changed afterwards
33 | // (cannot make them final since they are declared in superclass
34 | // but their values are specific to subclasses)
35 | isPersistent = false;
36 | isTransactional = true;
37 | isDirty = true;
38 | isNew = false;
39 | isDeleted = false;
40 |
41 | stateType = T_DIRTY;
42 | }
43 |
44 | @Override
45 | public LifeCycleState transitionMakeTransient(DNStateManager sm, boolean useFetchPlan, boolean detachAllOnCommit)
46 | {
47 | return this;
48 | }
49 |
50 | @Override
51 | public LifeCycleState transitionMakePersistent(DNStateManager sm)
52 | {
53 | sm.registerTransactional();
54 | return changeState(sm,P_NEW);
55 | }
56 |
57 | @Override
58 | public LifeCycleState transitionCommit(DNStateManager sm, Transaction tx)
59 | {
60 | sm.clearSavedFields();
61 | return changeTransientState(sm,T_CLEAN);
62 | }
63 |
64 | @Override
65 | public LifeCycleState transitionRollback(DNStateManager sm, Transaction tx)
66 | {
67 | if (tx.getRestoreValues() || sm.isRestoreValues())
68 | {
69 | sm.restoreFields();
70 | }
71 | return changeTransientState(sm,T_CLEAN);
72 | }
73 |
74 | /**
75 | * Method to return a string version of this object.
76 | * @return The string "T_DIRTY".
77 | */
78 | public String toString()
79 | {
80 | return "T_DIRTY";
81 | }
82 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/DateExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import java.sql.Date;
21 |
22 | import javax.jdo.query.DateExpression;
23 | import javax.jdo.query.NumericExpression;
24 | import javax.jdo.query.PersistableExpression;
25 |
26 | import org.datanucleus.store.query.expression.Expression;
27 | import org.datanucleus.store.query.expression.InvokeExpression;
28 |
29 | /**
30 | * Implementation of a Date expression.
31 | */
32 | public class DateExpressionImpl extends ComparableExpressionImpl implements DateExpression
33 | {
34 | public DateExpressionImpl(PersistableExpression parent, String name)
35 | {
36 | super(parent, name);
37 | }
38 |
39 | public DateExpressionImpl(Class cls, String name, ExpressionType type)
40 | {
41 | super(cls, name, type);
42 | }
43 |
44 | public DateExpressionImpl(Expression queryExpr)
45 | {
46 | super(queryExpr);
47 | }
48 |
49 | /* (non-Javadoc)
50 | * @see org.datanucleus.query.typesafe.DateExpression#getDay()
51 | */
52 | public NumericExpression getDay()
53 | {
54 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "getDay", null);
55 | return new NumericExpressionImpl(invokeExpr);
56 | }
57 |
58 | /* (non-Javadoc)
59 | * @see org.datanucleus.query.typesafe.DateExpression#getMonth()
60 | */
61 | public NumericExpression getMonth()
62 | {
63 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "getMonth", null);
64 | return new NumericExpressionImpl(invokeExpr);
65 | }
66 |
67 | /* (non-Javadoc)
68 | * @see org.datanucleus.query.typesafe.DateExpression#getYear()
69 | */
70 | public NumericExpression getYear()
71 | {
72 | org.datanucleus.store.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "getYear", null);
73 | return new NumericExpressionImpl(invokeExpr);
74 | }
75 | }
--------------------------------------------------------------------------------
/src/main/java/org/datanucleus/api/jdo/query/TimeExpressionImpl.java:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Copyright (c) 2010 Andy Jefferson and others. All rights reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Contributors:
16 | ...
17 | **********************************************************************/
18 | package org.datanucleus.api.jdo.query;
19 |
20 | import java.sql.Time;
21 |
22 | import javax.jdo.query.NumericExpression;
23 | import javax.jdo.query.PersistableExpression;
24 | import javax.jdo.query.TimeExpression;
25 |
26 | import org.datanucleus.store.query.expression.Expression;
27 | import org.datanucleus.store.query.expression.InvokeExpression;
28 |
29 | /**
30 | * Implementation of a Time expression.
31 | */
32 | public class TimeExpressionImpl extends ComparableExpressionImpl