Replies: 2 comments
-
My two cents on this: it feels strange rely on the deviceCode to be unique across all realms, as it seems no realm will be part of the primary key here. I'm surprised that those entities are not realm specific in the first place?! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Good point. According to our team discussion yesterday, here's the link to a new issue to make these entities realm-specific: #12462 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When implementing the JPA Map Storage for single-use objects, I came across an issue with the
MapSingleUseObjectEntity
id. Different services use different formats for their object keys, which are used as ids when interacting with theMapSingleUseObjectProvider
.For example, OAuth2DeviceCodeModel produces a key with the format
dc.
+deviceCode
. OAuth2DeviceUserCodeModel, on the other hand, produces a key that equalsrealmId
+.uc.
+userCode
. Other places, like theParEndpoint
, generate aUUID
key.These keys are taken by the
MapSingleUseObjectProvider
and used as the entity's id. So, whenget(String key)
is called, it retrieves the entity by this key by callingtx.read(key)
, which in JPA means this key is to be considered the entity's primary key. As this key can't be pinned to a specific format, we can't have a JPA entity with anId
column of typeUUID
, so in the initial PR I've usedString
instead for theId
column.The issue here is that this makes the
JpaSingleUseObjectEntity
different from all other entities we've implemented for the JPA Map storage, which all useUUID
, so we lose consistency in how the entities ids are defined.The alternative would be to have a different searchable field in
MapSingleUseObjectEntity
, calledobjectKey
or something like that, and change the provider to not search by primary key, but rather useModelCriteriaBuilder
to search by this new field. The id would then be generated by the store as UUID.I would like to get some opinions on this. Does it seem ok to have the
Id
for this entity as aString
, or is consistency more important to the point where we add a new field just to be able to map the id to UUID like the other JPA entities? How would something like that impact the hotrody impl, for example?Beta Was this translation helpful? Give feedback.
All reactions