I am writing an entity that has a tree like data structure. I am using embeddable objects as the nodes. These embeddable nodes must carry a 2D boolean array.
can I just do something like this:
@Embeddable
public class AwesomeNode implements Serializable{
private boolean[][] matrix;
// getters, setters and other stuff
}
I have been reading the documentation, and although all primitive types are supported, it seems that boolean arrays are not.
If this is indeed the case, I was planning on using a byte[width*height] (explicitly supported) and then just perform necessary logic on the user end. Is this a good idea? A better way of doing it?
Can anyone offer some guidance.
JPA is built in a manner that a field value can easily be stored in the relational data base. How whould you like to store a 2D array in a table?
You should answer to yourself on this question and you’ll see immediately how it should be mapped.
Example: if you say it will be binary representation than you should go for the BLOB mapping
Or, if you know how many columns will be in your matrix, you can probably dedicate a table for it each row in the table will be a row in you 2D array. The choice is yours, but yes, you can’t just take the 2D array and store it, it just doesn’t suite out of the box to be stored in the relational DB.
Hope this helps