|
|
|
allee8285-2
|
Author: allee8285
Date: Fri Oct 30 04:09:05 2009 New Revision: 831194 URL: http://svn.apache.org/viewvc?rev=831194&view=rev Log: OPENJPA-1306 - Add basic extended lock scope support, 3 junit testing basic, secondary table, join table, inheritance entity, element collections (lazy/eager), 1x1 (lazy/eager) and 1xm (lazy/eager). Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LockScopeTestCase.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/Test1x1LockScope.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/Test1xmLockScope.java (with props) openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/TestBasicLockScope.java (with props) openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/LockScopesHelper.java (with props) Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java?rev=831194&r1=831193&r2=831194&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java Fri Oct 30 04:09:05 2009 @@ -401,6 +401,23 @@ } } + public int getLockScope() { + try { + return _fetch.getLockScope(); + } catch (RuntimeException re) { + throw translate(re); + } + } + + public FetchConfiguration setLockScope(int scope) { + try { + _fetch.setLockScope(scope); + return this; + } catch (RuntimeException re) { + throw translate(re); + } + } + public int getReadLockLevel() { try { return _fetch.getReadLockLevel(); Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java?rev=831194&r1=831193&r2=831194&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java Fri Oct 30 04:09:05 2009 @@ -36,7 +36,7 @@ * @author Pinaki Poddar */ public interface FetchConfiguration - extends Serializable, Cloneable, LockLevels, QueryFlushModes { + extends Serializable, Cloneable, LockLevels, LockScopes, QueryFlushModes { /** * Constant to revert any setting back to its default value. @@ -268,7 +268,21 @@ * @since 0.3.1 */ public FetchConfiguration setLockTimeout(int timeout); - + + /** + * The lock scope for next fetch. + * + * @since 2.0.0 + */ + public int getLockScope(); + + /** + * The lock scope for next fetch. + * + * @since 2.0.0 + */ + public FetchConfiguration setLockScope(int scope); + /** * The number of milliseconds to wait for a query, or -1 for no * limit. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=831194&r1=831193&r2=831194&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Fri Oct 30 04:09:05 2009 @@ -78,7 +78,7 @@ public int flushQuery = 0; public int lockTimeout = -1; public int queryTimeout = -1; - public int lockMode = 0; + public int lockScope = LOCKSCOPE_NORMAL; public int readLockLevel = LOCK_NONE; public int writeLockLevel = LOCK_NONE; public Set<String> fetchGroups = null; @@ -168,6 +168,7 @@ setExtendedPathLookup(fetch.getExtendedPathLookup()); setLockTimeout(fetch.getLockTimeout()); setQueryTimeout(fetch.getQueryTimeout()); + setLockScope(fetch.getLockScope()); clearFetchGroups(); addFetchGroups(fetch.getFetchGroups()); clearFields(); @@ -482,6 +483,22 @@ return this; } + public int getLockScope() { + return _state.lockScope; + } + + public FetchConfiguration setLockScope(int scope) { + if (scope != DEFAULT + && scope != LockScopes.LOCKSCOPE_NORMAL + && scope != LockScopes.LOCKSCOPE_EXTENDED) + throw new IllegalArgumentException(_loc.get( + "bad-lock-scope", new Integer(scope)).getMessage()); + if (scope == DEFAULT ) + _state.lockScope = LOCKSCOPE_NORMAL; + else + _state.lockScope = scope; + return this; + } public int getReadLockLevel() { String lockModeKey = "openjpa.FetchPlan.ReadLockMode"; Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java (added) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.kernel; + +/** + * Defines lock scope levels used for MixedLockManager. + * + * @since 2.0.0 + */ +public interface LockScopes { + + /** + * Generic Normal lock scope level. Value of 0. + * + */ + public static final int LOCKSCOPE_NORMAL = 0; + + /** + * Generic extended lock scope level. Value of 10. + */ + public static final int LOCKSCOPE_EXTENDED = 10; + +} Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockScopes.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties?rev=831194&r1=831193&r2=831194&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties (original) +++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties Fri Oct 30 04:09:05 2009 @@ -448,4 +448,5 @@ occurred while invoking "{0}" with key "{1}" and value "{2}" of type "{3}". \ See nested exception for details. writebehind-cfg-err: Missing required WriteBehind configuration parameter "{0}" +bad-lock-scope: This lock manager does not recognize lock scope "{0}". Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1x1LfNormal" + , query="SELECT c FROM LSE1x1Lf c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1x1LfExtended" + , query="SELECT c FROM LSE1x1Lf c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1x1Lf implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToOne + private LSE1x1Rt uniRight; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public LSE1x1Rt getUniRight() { + return uniRight; + } + + public void setUniRight(LSE1x1Rt uniRight) { + this.uniRight = uniRight; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + "[id=" + getId() + + ", ver=" + getVersion() + ", firstName=" + firstName + "]" + + " uniRight=" + getUniRight() + ; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (LSE1x1Rt) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Lf.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1x1LfJTNormal" + , query="SELECT c FROM LSE1x1LfJT c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1x1LfJTExtended" + , query="SELECT c FROM LSE1x1LfJT c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1x1LfJT implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToOne + @JoinTable(name="Uni1x1LfJT_Uni1x1RT") + private LSE1x1Rt uniRightJT; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public LSE1x1Rt getUniRightJT() { + return uniRightJT; + } + + public void setUniRightJT(LSE1x1Rt uniRightJT) { + this.uniRightJT = uniRightJT; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + "[id=" + getId() + + ", ver=" + getVersion() + ", firstName=" + firstName + "]" + + " uniRightJT=" + getUniRightJT() + ; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRightJT = (LSE1x1Rt) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRightJT); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJT.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1x1LfJTLzyNormal" + , query="SELECT c FROM LSE1x1LfJTLzy c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1x1LfJTLzyExtended" + , query="SELECT c FROM LSE1x1LfJTLzy c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1x1LfJTLzy implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToOne(fetch=FetchType.LAZY) + @JoinTable(name="Uni1x1LfJT_Uni1x1RT") + private LSE1x1Rt uniRightJT; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public LSE1x1Rt getUniRightJT() { + return uniRightJT; + } + + public void setUniRightJT(LSE1x1Rt uniRightJT) { + this.uniRightJT = uniRightJT; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + "[id=" + getId() + + ", ver=" + getVersion() + ", firstName=" + firstName + "]" + + " uniRightJT=" + getUniRightJT() + ; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRightJT = (LSE1x1Rt) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRightJT); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfJTLzy.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1x1LfLzyNormal" + , query="SELECT c FROM LSE1x1LfLzy c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1x1LfLzyExtended" + , query="SELECT c FROM LSE1x1LfLzy c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1x1LfLzy implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToOne(fetch=FetchType.LAZY) + private LSE1x1Rt uniRight; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public LSE1x1Rt getUniRight() { + return uniRight; + } + + public void setUniRight(LSE1x1Rt uniRight) { + this.uniRight = uniRight; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + "[id=" + getId() + + ", ver=" + getVersion() + ", firstName=" + firstName + "]" + + " uniRight=" + getUniRight() + ; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (LSE1x1Rt) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1LfLzy.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; + +@Entity +public class LSE1x1Rt implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String lastName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", lastName=" + lastName + "]"; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + lastName = in.readUTF(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1x1Rt.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collection; +import java.util.HashSet; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1xmLfNormal" + , query="SELECT c FROM LSE1xmLf c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1xmLfExtended" + , query="SELECT c FROM LSE1xmLf c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1xmLf implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToMany // (cascade=CascadeType.ALL) (mappedBy="ownerOne") + private Collection<LSE1xmRt> uniRight = new HashSet<LSE1xmRt>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Collection<LSE1xmRt> getUniRight() { + return uniRight; + } + + public void setUnitRight(Collection<LSE1xmRt> uniRight) { + this.uniRight = uniRight; + } + + public void addUnitRight(LSE1xmRt uniRight) { + this.uniRight.add(uniRight); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + firstName + "] ownedMany=" + getUniRight(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (Collection<LSE1xmRt>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLf.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collection; +import java.util.HashSet; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1xmLfEgrNormal" + , query="SELECT c FROM LSE1xmLfEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1xmLfEgrExtended" + , query="SELECT c FROM LSE1xmLfEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1xmLfEgr implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToMany(fetch=FetchType.EAGER) //(mappedBy="ownerOne") + private Collection<LSE1xmRt> uniRight = new HashSet<LSE1xmRt>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Collection<LSE1xmRt> getUniRight() { + return uniRight; + } + + public void setUnitRight(Collection<LSE1xmRt> uniRight) { + this.uniRight = uniRight; + } + + public void addUnitRight(LSE1xmRt uniRight) { + this.uniRight.add(uniRight); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + firstName + "] ownedMany=" + getUniRight(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (Collection<LSE1xmRt>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfEgr.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collection; +import java.util.HashSet; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1xmLfJTNormal" + , query="SELECT c FROM LSE1xmLfJT c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1xmLfJTExtended" + , query="SELECT c FROM LSE1xmLfJT c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1xmLfJT implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @JoinTable + @OneToMany //(mappedBy="ownerOne") + private Collection<LSE1xmRt> uniRight = new HashSet<LSE1xmRt>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Collection<LSE1xmRt> getUniRight() { + return uniRight; + } + + public void setUnitRight(Collection<LSE1xmRt> uniRight) { + this.uniRight = uniRight; + } + + public void addUnitRight(LSE1xmRt uniRight) { + this.uniRight.add(uniRight); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + firstName + "] ownedMany=" + getUniRight(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (Collection<LSE1xmRt>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJT.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collection; +import java.util.HashSet; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSE1xmLfJTEgrNormal" + , query="SELECT c FROM LSE1xmLfJTEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSE1xmLfJTEgrExtended" + , query="SELECT c FROM LSE1xmLfJTEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSE1xmLfJTEgr implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @OneToMany(fetch=FetchType.EAGER)//(mappedBy="ownerOne") + private Collection<LSE1xmRt> uniRight = new HashSet<LSE1xmRt>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Collection<LSE1xmRt> getUniRight() { + return uniRight; + } + + public void setUnitRight(Collection<LSE1xmRt> uniRight) { + this.uniRight = uniRight; + } + + public void addUnitRight(LSE1xmRt uniRight) { + this.uniRight.add(uniRight); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + firstName + "] ownedMany=" + getUniRight(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + uniRight = (Collection<LSE1xmRt>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(uniRight); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmLfJTEgr.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; + +@Entity +public class LSE1xmRt implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String lastName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", lastName=" + lastName + "]"; + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + lastName = in.readUTF(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSE1xmRt.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSEBaseNormal" + , query="SELECT c FROM LSEBase c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSEBaseExtended" + , query="SELECT c FROM LSEBase c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } +) + +@Entity +public class LSEBase implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + private String lastName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + "] first=" + getFirstName() + + ", last=" + getLastName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = (String) in.readObject(); + lastName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeObject(firstName); + out.writeObject(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEBase.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSEEleColNormal" + , query="SELECT c FROM LSEEleCol c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSEEleColExtended" + , query="SELECT c FROM LSEEleCol c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSEEleCol implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @ElementCollection + protected Set<String> collection = new HashSet<String>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String name) { + this.firstName = name; + } + + public Set<String> getCollection() { + return collection; + } + + public void setCollection(Set<String> collection) { + this.collection = collection; + } + + public void addCollection(String element) { + collection.add(element); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + getFirstName() + "] one=" + getCollection(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + collection = (Set<String>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(collection); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleCol.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSEEleColEgrNormal" + , query="SELECT c FROM LSEEleColEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSEEleColEgrExtended" + , query="SELECT c FROM LSEEleColEgr c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSEEleColEgr implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + + @ElementCollection(fetch=FetchType.EAGER) + protected Set<String> collection = new HashSet<String>(); + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String name) { + this.firstName = name; + } + + public Set<String> getCollection() { + return collection; + } + + public void setCollection(Set<String> collection) { + this.collection = collection; + } + + public void addCollection(String element) { + collection.add(element); + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + ", firstName=" + getFirstName() + "] one=" + getCollection(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = in.readUTF(); + collection = (Set<String>) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeUTF(firstName); + out.writeObject(collection); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEEleColEgr.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Version; + +@Entity +@Inheritance(strategy=InheritanceType.JOINED) +public abstract class LSEJoinAbs implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + "] first=" + getFirstName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeObject(firstName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinAbs.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSEJoinConNormal" + , query="SELECT c FROM LSEJoinCon c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSEJoinConExtended" + , query="SELECT c FROM LSEJoinCon c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSEJoinCon extends LSEJoinAbs implements Externalizable { + + private String lastName; + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + super.toString() + + ", last=" + getLastName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + super.readExternal(in); + lastName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + out.writeObject(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSEJoinCon.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.SecondaryTable; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSESecTblNormal" + , query="SELECT c FROM LSESecTbl c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSESecTblExtended" + , query="SELECT c FROM LSESecTbl c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +@SecondaryTable(name="LSESecTblDtl") +public class LSESecTbl implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + @Column(table="LSESecTblDtl") + private String lastName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + "[id=" + getId() + + ", ver=" + getVersion() + "] first=" + getFirstName() + ", last=" + getLastName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = (String) in.readObject(); + lastName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeObject(firstName); + out.writeObject(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESecTbl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; +import javax.persistence.Version; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSESngTblAbsNormal" + , query="SELECT c FROM LSESngTblAbs c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSESngTblAbsExtended" + , query="SELECT c FROM LSESngTblAbs c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +public abstract class LSESngTblAbs implements Externalizable { + + @Id + private int id; + + @Version + private int version; + + private String firstName; + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public int getVersion() { + return version; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + "[id=" + + getId() + ", ver=" + getVersion() + "] first=" + getFirstName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + id = in.readInt(); + version = in.readInt(); + firstName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(id); + out.writeInt(version); + out.writeObject(firstName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblAbs.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java?rev=831194&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java (added) +++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java Fri Oct 30 04:09:05 2009 @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.lock.extended; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import javax.persistence.Entity; +import javax.persistence.LockModeType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.QueryHint; + +@NamedQueries ( value={ + @NamedQuery( + name="findLSESngTblConNormal" + , query="SELECT c FROM LSESngTblCon c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + ), + @NamedQuery( + name="findLSESngTblConExtended" + , query="SELECT c FROM LSESngTblCon c WHERE c.firstName LIKE :firstName" + , lockMode=LockModeType.PESSIMISTIC_WRITE + , hints={@QueryHint(name="javax.persistence.lock.scope",value="EXTENDED")} + ) + } + ) + +@Entity +public class LSESngTblCon extends LSESngTblAbs implements Externalizable { + + private String lastName; + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String toString() { + return this.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(this)) + super.toString() + + ", last=" + getLastName(); + } + + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException { + super.readExternal(in); + lastName = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + out.writeObject(lastName); + } +} Propchange: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lock/extended/LSESngTblCon.java ------------------------------------------------------------------------------ svn:eol-style = native |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |