I have never used ARRAY type (and never will :)
But few things come to my mind immediately.
First how does H2 know that you have an array of integers?
In the table definition you only say ARRAY.
Maybe it is an ARRAY of bytes or cars or .. whatever
Most likely it is an array of objects.
And hey that's exactly what the error message says!
Why don't you just model your data like this:
create table userdata(userid int primary key);
create table friends(friendid int primary key, userid int references
userdata(userid));
Now you can set constraints better to values and know your types better.
This foolery with arrays in the relational database is just asking for
trouble.
(Yes I know, I am being provocative).
- rami
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/qokF3f6ZtxcJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
Then you want to store the information of user's friendships with each
other, right?
That is a many-to-many relationship between user and and another user.
Further the relationship is symmetric (well at least one would hope for
mutual feelings).
So I would come up with a new entity/concept/substantive FRIENDSHIP.
It would have columns
- FRIENDSHIP_ID (primary key, every table needs an identity)
- USER1 references USER table
- USER2 references USER table
Now you can for example define that a user can not be friend of himself.
CHECK(USER1 <> USER2)
You can define that do not store one friendship more than once
UNIQUE(USER1, USER2)
I don't think it is possible to disallow USER2 -> USER1 if you already
have USER1 -> USER2 ... bummer
Anyway you can be assured that all friendships stored are between
EXISTING users (no nullpointer exceptions).
- rami
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/kNJ1EmbkyW0J.
Object objs = rs.getObject("arraycoloum");