Question

I've seen a lot of Kundera examples where the object being store is fairly simple. You have something like a Car.class and it contains a couple String variables maybe an int mapped using the @Column annotation. I've even seen some List, Set and Map variables as well as the cqlsh to create a column of those types.

What I haven't seen is a custom object I created within an object and how that would be represented in a Cassandra DB.

For example:

public Class ContainerShip {

    @Column(name="container")
    Container myContainer;
}

public Class Container {
    @Column(name="containerName)
    String containerName;
}

Could I store ContainerShip into Cassandra, using Kundera with em.persist(myShip)?

If I can what would the cqlsh for creating the "container" column look like?

Was it helpful?

Solution

You may embed a container object as an embeddable entity.

@Entity public Class ContainerShip {

@Column(name="container")
@Embedded
Container myContainer;

}

@Embeddable public Class Container {

@Column(name="containerName)
String containerName;

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top