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 @@ -102,7 +102,7 @@
*/
@MappedSuperclass
@EntityListeners(BaseEntityListener.class)
public abstract class BaseEntity<I extends Comparable<I> & Serializable> implements Comparable<BaseEntity<I>>, Identifiable<I> {
public abstract class BaseEntity<I extends Comparable<I> & Serializable> implements Comparable<BaseEntity<I>>, Identifiable<I>, Serializable {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @see BaseEntity
* @see BaseEntityService
*/
public interface Identifiable<I extends Comparable<I> & Serializable> extends Serializable {
public interface Identifiable<I extends Comparable<I> & Serializable> {

/**
* The string representing the field name <code>"id"</code>.
Expand Down
46 changes: 46 additions & 0 deletions src/test/java/org/omnifaces/persistence/test/IdentifiableTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright OmniFaces
*
* Licensed 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
*
* https://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.omnifaces.persistence.test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.omnifaces.persistence.test.Serializations.serializeAndDeserialize;

import java.io.Serializable;

import org.junit.jupiter.api.Test;
import org.omnifaces.persistence.model.BaseEntity;
import org.omnifaces.persistence.model.Identifiable;
import org.omnifaces.persistence.test.model.Person;

/**
* {@link Identifiable} does not require its implementations to be serializable, but {@link BaseEntity} and therefore all its subclasses are.
*/
class IdentifiableTest {

@Test
void identifiableIsNotSerializable() {
assertFalse(Serializable.class.isAssignableFrom(Identifiable.class));
}

@Test
void baseEntityIsSerializable() throws Exception {
assertTrue(Serializable.class.isAssignableFrom(BaseEntity.class));

var person = new Person();
person.setId(42L);
assertEquals(person, serializeAndDeserialize(person));
}

}
Loading