data-jpa-3-to-4: Spring Data JPA 3.5 vs 4.2 side by side - package moves, nullness, Specification, keyset, Page JSON, Jackson 3, test slices, real transcripts
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7N4ZDbUtA3ofqAqRV
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
3f061c5e5d
commit
7a2bcc1eb6
@@ -0,0 +1,9 @@
|
||||
import com.ankurm.jpamig.domain.Book;
|
||||
import com.ankurm.jpamig.repo.BookRepository;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
class DeleteBySpecification {
|
||||
long purge(BookRepository books, Specification<Book> old) {
|
||||
return books.delete(old);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import com.ankurm.jpamig.domain.Book;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
class HibernateSessionApi {
|
||||
@Where(clause = "deleted = false")
|
||||
java.util.List<Book> filtered;
|
||||
|
||||
void write(Session session, Book book) {
|
||||
session.save(book);
|
||||
session.saveOrUpdate(book);
|
||||
session.update(book);
|
||||
session.delete(book);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
|
||||
class JacksonCustomizer {
|
||||
Jackson2ObjectMapperBuilderCustomizer dates() {
|
||||
return builder -> builder.simpleDateFormat("dd.MM.yyyy");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.mapping.PropertyReferenceException;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
|
||||
class PackageMoves {
|
||||
TypeInformation<?> t = TypeInformation.of(String.class);
|
||||
PropertyPath p;
|
||||
PropertyReferenceException e;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import org.springframework.data.querydsl.QPageRequest;
|
||||
|
||||
class QueryDslPaging {
|
||||
Object first() {
|
||||
return new QPageRequest(0, 20);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
|
||||
class RemovedAnnotations {
|
||||
@PersistenceConstructor
|
||||
RemovedAnnotations() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import com.ankurm.jpamig.domain.Book;
|
||||
import com.ankurm.jpamig.repo.BookRepository;
|
||||
|
||||
/** Deprecated long ago, still present in Spring Data JPA 4.2: warnings, not errors. */
|
||||
class StillCompiles {
|
||||
void old(BookRepository books) {
|
||||
Book a = books.getOne(1L);
|
||||
Book b = books.getById(1L);
|
||||
books.deleteInBatch(java.util.List.of(a, b));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
|
||||
class TestSliceImports {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import com.ankurm.jpamig.domain.Book;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
class WhereNull {
|
||||
Specification<Book> start() {
|
||||
return Specification.where(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
class Invoice {
|
||||
@Id Long id;
|
||||
@Embedded Amount total;
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
record Amount(java.math.BigDecimal value, String currency) {
|
||||
}
|
||||
Reference in New Issue
Block a user