Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
Are JavaBeans No Longer Required to Be Serializable?

I'm a C# developer who has recently been thrown onto a Java team at my company. We use Jakarta Bean Validation in our spring-based microservices, and I've been trying to read through the specification to get a better understanding of the framework. However, I've noticed what I believe to be an inconsistency in the documentation.

When reading through the Jakarta Bean Validation specification (https://beanvalidation.org/2.0/spec/), it states that "the Jakarta Bean Validation specification defines a framework for declaring constraints on JavaBean classes, fields and properties.

Later on in the specification, it uses the following class as an example JavaBean to demonstrate the validation annotations provided by the framework.

public class Address {

@NotNull @Size(max=30)
private String addressline1;

@Size(max=30)
private String addressline2;

private String zipCode;

private String city;

public String getAddressline1() {
    return addressline1;
}

public void setAddressline1(String addressline1) {
    this.addressline1 = addressline1;
}

public String getAddressline2() {
    return addressline2;
}

public void setAddressline2(String addressline2) {
    this.addressline2 = addressline2;
}

public String getZipCode() {
    return zipCode;
}

public void setZipCode(String zipCode) {
    this.zipCode = zipCode;
}

@Size(max=30) @NotNull
public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

}

However, based on what I have read online, this class does not fit the definition of a JavaBean, since it does not implement the Serializable interface.

In the very next paragraph (https://beanvalidation.org/2.0/spec/#constraintdeclarationvalidationprocess-requirements), the specification then states that the only real requirement of classes to be validated is that they follow the getter/setter convention of the JavaBeans spec.

So, if the specification is named Java Bean Validation, and they explicitly state the goal is to define constraints on JavaBean classes, then why does the example and constraint requirements not adhere to the need for serializability?

Are JavaBeans no longer required to be serializable or is this documentation actually inconsistent?

I realize I'm probably overthinking this, but as someone new to the Java ecosystem, I'd like to make sure I have a strong understanding of fundamentals like this.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda