Repository navigation
4.0.0-M1 Release #926
gavinking
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Jakarta Persistence 4.0 Milestone 1
Specification draft: jakarta-persistence-spec-4.0-M1.pdf
Maven central: https://central.sonatype.com/artifact/jakarta.persistence/jakarta.persistence-api/4.0.0-M1
Announcement: https://in.relation.to/2026/01/20/JPA-4-M1/
Changelog
Changes to API
Added
EntityAgentandEntityHandlerAdded
@StaticQuery,@StaticNativeQuery,@ReadQueryOptions,@WriteQueryOptionsandStaticStatementReferencefor declaring static queries at the method level, along with additional members ofTypedQueryReferenceAdded a new API for programmatic SQL result set mappings
Added
Statement,CriteriaStatement,@NamedStatementand@NamedNativeStatementto clearly distinguish statements which modify data from queries which return data; addedofType(),withEntityGraph(), andasStatement()toQueryAdded
@NamedEntityGraphAttributeNodeand@NamedEntityGraphSubgraphfor more elegant definition of named entity graphsAdded the ability to select
LAZYfetching as the default for@OneToOneand@ManyToOneassociations via<default-to-one-fetch-type>inpersistence.xmlorPersistenceConfiguration.defaultToOneFetchType()Added
get()operation as an alternative tofind(); addedfindMultiple()andgetMultiple()Added
getResultCount()toTypedQueryAdded
registerResultParameter()toStoredProcedureQueryFor much improved type safety, overloaded
getResultList(),getSingleResult(), andgetSingleResultOrNull()onStoredProcedureQuery; addedregisterParameter(); and added an overload ofgetOutputParameterValue()Made
StoredProcedureQuerya subtype ofAutoCloseableAdded
@ExcludedFromVersioningAdded
FETCHEDtoPessimisticLockScope,lockScopeto@NamedQuery, andsetLockScope()toQueryAdded new lifecycle callback types:
@PreMerge,@PreInsert,@PostInsert,@PreUpsert,@PostUpsert,@PreDelete,@PostDeleteAdded
addListener()toEntityManagerFactorySpecify that an entity listener may have multiple callbacks of the same type
Added
setEntityGraph()toTypedQuery,entityGraphto@NamedQuery, and overloadedcreateQuery(String, EntityGraph)onEntityManager.Specified that the graph returned by
getEntityGraph()is now mutable, and addedgetEntityGraph(Class, String)Added
createEntityGraph()andgetNamedEntityGraphs()toEntityTypeAdded
Graph.getGraphedType()andAttributeNode.getAttribute()Overloaded
addNamedQuery()to takeTypedQueryand returnTypedQueryReferenceand addedaddNamedStatement()Added overloads of
setParameter()which accept a disambiguatingClassorType; addedsetConvertedParameter()toQueryandregisterConvertedParameter()toStoredProcedureQuery; addedconvertedParameter()toCriteriaBuilderChanges to Query Language
Made
select new X(...)optional in JPQL queries with an explicit result class of typeX, and allowed the result class of a native SQL query to be interpreted as a constructor resultSpecify that entity names must be legal Java identifiers
Made
ELSEbranch inCASEexpressions optional in JPQLChanges to Configuration and Bootstrap
Allow named queries and statements to be defined on non-managed classes and interfaces.
Overloaded
Persistence.generateSchema()to acceptPersistenceConfigurationand added related functionality toPersistenceConfiguration:exportSchema(),schemaManagementDatabaseAction(),schemaManagementScriptsAction(),SchemaManagementActionAdded
jakarta.persistence.jdbc.fetchSizeandjakarta.persistence.jdbc.batchSize, and promoted schema export specific propertiesjakarta.persistence.database-*to APIAdded static lists of standard property names to inner interfaces of
PersistenceFixed
SCHEMAGEN_CREATE_TARGET,SCHEMAGEN_DROP_TARGET, and addedSCHEMAGEN_LOAD_SCRIPT_SOURCEtoPersistenceConfigurationAdded
SchemaManager.populate()and the new schema generation actionpopulate()Redefine automatic bean validation. By default, automatic validation
is now expected after pre-insert, pre-update and pre-upsert lifecycle
events instead of previously used pre-persist, pre-update ones.
Automatic bean validation can be enabled after the following lifecycle
events: pre-persist, pre-merge, pre-remove, pre-delete.
Minor Changes and Fixes
jakarta.annotation.Nonnullnow impliesoptional=falseAllow
@EntityResultas a subelement of@ConstructorResultin named SQL result set mappingsAllow
valuemember of@JoinColumnsto be defaultedAdded
commentmember to@DiscriminatorColumn,@MapKeyColumn,@MapKeyJoinColumn,@PrimaryKeyJoinColumnand@CollectionTableAdded
checkmember to@MapKeyColumn,@MapKeyJoinColumn,@PrimaryKeyJoinColumnand@CollectionTableChange default
lockModeofEntityResulttoNONEFixed some incorrect generic method signatures in
FromFixed use of raw types in
AttributeNodeAdded
PersistenceUnitInfo.getAllManagedClassNames()andPersistenceProvider.getClassTransformer()Deprecations
Deprecated many operations of
Query, since those operations should now be executed via aStatementorTypedQueryDeprecated
createEntityGraph(String)Deprecated
EntityManager.getDelegate()in favor ofunwrap()Deprecated
namemember of@MapKeyin favor ofvalueRemovals
Deleted APIs marked deprecated for removal
Removed redundant overloads of
find()andrefresh()acceptingLockModeTypeRemoved deprecated support for use of
Byte[]andCharacter[]as basic typesAll reactions