Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ private static void buildProperty(
propertyBinder.setInheritanceStatePerClass( inheritanceStatePerClass );
propertyBinder.setId( !entityBinder.isIgnoreIdAnnotations() && hasIdAnnotation( property ) );

if ( isPropertyOfRegularEmbeddable( propertyHolder, isComponentEmbedded )
&& property.hasDirectAnnotationUsage(Id.class)) {
throw new AnnotationException("Member '" + property.getName()
+ "' of embeddable class " + propertyHolder.getClassName() + " is annotated '@Id'");
}

final LazyGroup lazyGroupAnnotation = property.getDirectAnnotationUsage( LazyGroup.class );
if ( lazyGroupAnnotation != null ) {
propertyBinder.setLazyGroup( lazyGroupAnnotation.value() );
Expand All @@ -805,6 +811,12 @@ private static void buildProperty(
addNaturalIds( inSecondPass, property, columns, joinColumns, context );
}

private static boolean isPropertyOfRegularEmbeddable(PropertyHolder propertyHolder, boolean isComponentEmbedded) {
return propertyHolder.isComponent() // it's a field of some sort of composite value
&& !propertyHolder.isInIdClass() // it's not a field of an id class
&& !isComponentEmbedded; // it's not an entity field matching a field of the id class
}

private static AnnotatedColumns bindProperty(
PropertyHolder propertyHolder,
Nullability nullability,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("serial")
public class Location implements Serializable {
public double longitude;
public double latitude;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.orm.test.inheritance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setCar(Car car) {
@Embeddable
public static class Car {

@Id
@Column(insertable = false, updatable = false)
private Integer id;

// represents a unidirectional one-to-one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.orm.test.query.hql.instantiation;

import org.hibernate.annotations.Imported;
Expand Down