Skip to content

Commit

Permalink
Fixed build issues with JPA API 3.2
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <tomas.kraus@oracle.com>
  • Loading branch information
Tomas-Kraus authored and lukasj committed Sep 20, 2023
1 parent f7070a1 commit f24afd7
Show file tree
Hide file tree
Showing 23 changed files with 370 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Date;
import java.util.Map;

import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class Alias {
private String alias;
@ElementCollection
@Temporal(TemporalType.DATE)
@SuppressWarnings("deprecation")
private Map<String, Date> ids;
private Customer customer;
@JoinColumn(name="ID", referencedColumnName="ALIAS.ALIAS")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package jpql.query;

import java.util.Date;

import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToOne;
Expand All @@ -27,13 +28,15 @@ public class LargeProject extends Project {

@Basic
@Temporal(TemporalType.DATE)
@SuppressWarnings("deprecation")
private Date endDate;

@OneToOne
private Project parent;

@Basic
@Temporal(TemporalType.DATE)
@SuppressWarnings("deprecation")
private Date startDate;

public LargeProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package jpql.query;

import java.util.Date;

import jakarta.persistence.Embeddable;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
Expand All @@ -21,6 +22,7 @@
public class ShelfLife {

@Temporal(TemporalType.DATE)
@SuppressWarnings("deprecation")
private Date soldDate;

public Date getSoldDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ public X getSingleResult() {
return (X) super.getSingleResult();
}

// TODO-API-3.2
//@Override
public X getSingleResultOrNull() {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Set the position of the first result to retrieve.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import jakarta.persistence.EntityGraph;
import jakarta.persistence.Subgraph;
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.MapAttribute;
import jakarta.persistence.metamodel.PluralAttribute;

import org.eclipse.persistence.descriptors.ClassDescriptor;
Expand Down Expand Up @@ -78,6 +79,24 @@ public String getName() {
return attributeGroup.getName();
}

// TODO-API-3.2
//@Override
public <S extends X> Subgraph<S> addTreatedSubgraph(Class<S> aClass) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public void addAttributeNode(String s) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public void addAttributeNode(Attribute<? super X, ?> attribute) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

@Override
public void addAttributeNodes(String... attributeNames) {
if (!this.isMutable) {
Expand All @@ -103,19 +122,19 @@ protected void addAttributeNodeImpl(AttributeNodeImpl attributeNode) {
}

@Override
public void addAttributeNodes(Attribute<X, ?>... attribute) {
public void addAttributeNodes(Attribute<? super X, ?>... attribute) {
if (!this.isMutable) {
throw new IllegalStateException("immutable_entitygraph");
}
for (Attribute<X, ?> attrNode : attribute) {
for (Attribute<? super X, ?> attrNode : attribute) {
this.addAttributeNodeImpl(new AttributeNodeImpl<X>(attrNode.getName()));
//order is important here, must add attribute node to node list before adding to group or it will appear in node list twice.
this.attributeGroup.addAttribute(attrNode.getName());
}
}

@Override
public <T> Subgraph<T> addSubgraph(Attribute<X, T> attribute) {
public <T> Subgraph<T> addSubgraph(Attribute<? super X, T> attribute) {
Class<T> type = attribute.getJavaType();
if (attribute.isCollection()) {
type = ((PluralAttribute) attribute).getBindableJavaType();
Expand All @@ -124,7 +143,13 @@ public <T> Subgraph<T> addSubgraph(Attribute<X, T> attribute) {
}

@Override
public <T> Subgraph<? extends T> addSubgraph(Attribute<X, T> attribute, Class<? extends T> type) {
public <Y> Subgraph<Y> addTreatedSubgraph(Attribute<? super X, ? super Y> attribute, Class<Y> aClass) {
return null;
}

@Override
@SuppressWarnings("removal")
public <T> Subgraph<? extends T> addSubgraph(Attribute<? super X, T> attribute, Class<? extends T> type) {
return addSubgraph(attribute.getName(), type);
}

Expand Down Expand Up @@ -169,7 +194,38 @@ public <X> Subgraph<X> addSubgraph(String attributeName, Class<X> type) {
}

@Override
public <T> Subgraph<T> addKeySubgraph(Attribute<X, T> attribute) {
public <E> Subgraph<E> addElementSubgraph(PluralAttribute<? super X, ?, E> pluralAttribute) {
return null;
}

@Override
public <E> Subgraph<E> addTreatedElementSubgraph(PluralAttribute<? super X, ?, ? super E> pluralAttribute, Class<E> aClass) {
return null;
}

@Override
public <X1> Subgraph<X1> addElementSubgraph(String s) {
return null;
}

@Override
public <X1> Subgraph<X1> addElementSubgraph(String s, Class<X1> aClass) {
return null;
}

@Override
public <K> Subgraph<K> addMapKeySubgraph(MapAttribute<? super X, K, ?> mapAttribute) {
return null;
}

@Override
public <K> Subgraph<K> addTreatedMapKeySubgraph(MapAttribute<? super X, ? super K, ?> mapAttribute, Class<K> aClass) {
return null;
}

@Override
@SuppressWarnings("removal")
public <T> Subgraph<T> addKeySubgraph(Attribute<? super X, T> attribute) {
if (!this.isMutable) {
throw new IllegalStateException("immutable_entitygraph");
}
Expand All @@ -181,7 +237,8 @@ public <T> Subgraph<T> addKeySubgraph(Attribute<X, T> attribute) {
}

@Override
public <T> Subgraph<? extends T> addKeySubgraph(Attribute<X, T> attribute, Class<? extends T> type) {
@SuppressWarnings("removal")
public <T> Subgraph<? extends T> addKeySubgraph(Attribute<? super X, T> attribute, Class<? extends T> type) {
return addKeySubgraph(attribute.getName(), type);
}

Expand Down Expand Up @@ -229,6 +286,7 @@ public <X> Subgraph<X> addKeySubgraph(String attributeName, Class<X> type) {
}

@Override
@SuppressWarnings("removal")
public <T> Subgraph<? extends T> addSubclassSubgraph(Class<? extends T> type) {
if (!this.isMutable) {
throw new IllegalStateException("immutable_entitygraph");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import jakarta.persistence.Query;
import jakarta.persistence.SynchronizationType;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.Metamodel;

import org.eclipse.persistence.config.EntityManagerProperties;
Expand Down Expand Up @@ -364,6 +365,7 @@ protected void verifyOpen() {
}

@Override
@SuppressWarnings("removal")
protected void finalize() throws Throwable {
if (isOpen()) {
close();
Expand Down Expand Up @@ -717,6 +719,12 @@ public boolean isLoaded(Object entity, String attributeName) {
return false;
}

// TODO-API-3.2
//@Override
public <E> boolean isLoaded(E e, Attribute<? super E, ?> attribute) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Determine the load state of an entity belonging to the persistence unit.
* This method can be used to determine the load state of an entity passed
Expand All @@ -738,6 +746,36 @@ public boolean isLoaded(Object entity) {
return false;
}

// TODO-API-3.2
//@Override
public void load(Object o, String s) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public <E> void load(E e, Attribute<? super E, ?> attribute) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public void load(Object o) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public boolean isInstance(Object o, Class<?> aClass) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public <T> Class<? extends T> getClass(T t) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Returns the id of the entity. A generated id is not guaranteed to be
* available until after the database insert has occurred. Returns null if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;

import jakarta.persistence.Cache;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.EntityTransaction;
import jakarta.persistence.FlushModeType;
import jakarta.persistence.PersistenceException;
import jakarta.persistence.PersistenceUnitUtil;
import jakarta.persistence.Query;
import jakarta.persistence.SynchronizationType;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.Metamodel;

import org.eclipse.persistence.config.ReferenceMode;
Expand Down Expand Up @@ -584,6 +588,12 @@ public boolean isLoaded(Object entity, String attributeName) {
return delegate.isLoaded(entity, attributeName);
}

// TODO-API-3.2
//@Override
public <E> boolean isLoaded(E e, Attribute<? super E, ?> attribute) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Determine the load state of an entity belonging to the persistence unit.
* This method can be used to determine the load state of an entity passed
Expand All @@ -602,6 +612,36 @@ public boolean isLoaded(Object entity) {
return delegate.isLoaded(entity);
}

// TODO-API-3.2
//@Override
public void load(Object o, String s) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public <E> void load(E e, Attribute<? super E, ?> attribute) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public void load(Object o) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public boolean isInstance(Object o, Class<?> aClass) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

// TODO-API-3.2
//@Override
public <T> Class<? extends T> getClass(T t) {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Returns the id of the entity. A generated id is not guaranteed to be
* available until after the database insert has occurred. Returns null if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ public int executeUpdate() {
* Finalize method in case the query is not closed.
*/
@Override
@SuppressWarnings("removal")
public void finalize() {
close();
}
Expand Down Expand Up @@ -697,6 +698,12 @@ public Object getSingleResult() {
}
}

// TODO-API-3.2
//@Override
public Object getSingleResultOrNull() {
throw new UnsupportedOperationException("Jakarta Persistence 3.2 API was not implemented yet");
}

/**
* Returns the update count or -1 if there is no pending result
* or if the next result is not an update count.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,22 @@ public <Y> Path<Y> get(SingularAttribute<? super E, Y> att){
* Return the path corresponding to the referenced collection-valued
* attribute.
*
* @param collection
* collection-valued attribute
* @param collection collection-valued attribute
* @return expression corresponding to the referenced attribute
*/
@Override
public <Y, C extends java.util.Collection<Y>> Expression<C> get(PluralAttribute<E, C, Y> collection){
public <Y, C extends java.util.Collection<Y>> Expression<C> get(PluralAttribute<? super E, C, Y> collection){
throw new IllegalStateException(ExceptionLocalization.buildMessage("pathnode_is_primitive_node"));
}

/**
* Return the path corresponding to the referenced map-valued attribute.
*
* @param map
* map-valued attribute
* @param map map-valued attribute
* @return expression corresponding to the referenced attribute
*/
@Override
public <L, W, M extends java.util.Map<L, W>> Expression<M> get(MapAttribute<E, L, W> map){
public <L, W, M extends java.util.Map<L, W>> Expression<M> get(MapAttribute<? super E, L, W> map){
throw new IllegalStateException(ExceptionLocalization.buildMessage("pathnode_is_primitive_node"));
}

Expand Down

0 comments on commit f24afd7

Please sign in to comment.