Q:

How exactly works this Hibernate entity class? How to correctly define a field representd by another entity class?

I am pretty new in Hibernate and I have the following doubt.
I have this entity class:
@Entity
@Table(name = "KM_COUNTRY_AREA")
public class KMCountryArea implements Serializable {

    @Id
    @GeneratedValue
    private Long idCountryArea;

    @Column(name = "nomeFolder")
    private String nomeFolder;

    @Column(name = "country")
    private KMCountry country;

    // GETTER & SETTER METHODS

}

I have a doubt related to this field definition:
@Column(name = "country")
private KMCountry country;

where KMCountry is another entity class. So what it exactly means? I think that Hibernate automatically use the id of the table mappend by the KMCountry class.
Is it correct or am I missing something?
EDIT-1:
So I have changed from:
@Column(name = "country")
private KMCountry country;

to:
@OneToOne(mappedBy = "country", cascade = CascadeType.ALL)
private KMCountry country;

where country is the name of the field that will contain the KMCountry id into the KM_COUNTRY_AREA table on my DB. Is it correct?
or maybe the correct syntax is:
@OneToOne
private KMCountry country;

because I have to use the primary key of the KMCountry country object?
What is the meaning of the cascade = CascadeType.ALL attribute?
Tnx

A:

You can't define it using the @Column annotation, you have to use Mapping entity associations/relationships.
And depending on your case I think you can use the One-to-one mapping.
Take a look at this tutorial:

Hibernate One to One Mapping (Annotation) Example.

Edit:
To answer the questions in your EDIT:

The field definition:

Use the following code to define your field:
@OneToOne(mappedBy = "countryArea", cascade = CascadeType.ALL)
private KMCountry country;

Where countryArea refers to the field you have to add in your KMcountry class like the following:
@OneToOne  
@PrimaryKeyJoinColumn  
private KMCountryArea countryArea; 

And in your DB you will only have a reference to the KMCountryArea id in your KM_Country table.

The meaning of cascade = CascadeType.ALL:

Cascading is about keeping dependency between two entities, for
example deletion of one object from the database causing deletion of
other dependent objects and CascadeType.ALL means that all the changes at parent class object will effect child class object too

JPA Cascade Types :
The cascade types supported by the Java Persistence Architecture are as below:

CascadeType.PERSIST : means that save() or persist() operations cascade to related entities.
CascadeType.MERGE : means that related entities are merged into managed state when the owning entity is merged.
CascadeType.REFRESH : does the same thing for the refresh() operation.
CascadeType.REMOVE : removes all related entities association with this setting when the owning entity is deleted.
CascadeType.DETACH : detaches all related entities if a “manual detach” occurs.
CascadeType.ALL : is shorthand for all of the above cascade operations.

Take a look at Hibernate Annotations-Cascade and Hibernate JPA Cascade Types for further information.

