Skip to content

Instantly share code, notes, and snippets.

@gbadner
Created February 19, 2014 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbadner/9099683 to your computer and use it in GitHub Desktop.
Save gbadner/9099683 to your computer and use it in GitHub Desktop.
Different types of Type
(11:26:53 AM) sebersole: i almost want to make it build the "domain model" first
(11:27:23 AM) sebersole: and use that to reference class names, attributes, etc
(11:27:34 AM) gbadner: +1
(11:28:03 AM) gbadner: I understand now why you had Type.getClassName() and getClassReference()
(11:29:00 AM) gbadner: it would be really nice if o.h.metamodel.spi.Type encapsulated HibernateTypeDescription
(11:29:15 AM) sebersole: it cant always
(11:29:30 AM) sebersole: especially in the case of composites
(11:29:56 AM) sebersole: think the distinction between Embeddable and Embedded
(11:30:13 AM) sebersole: Type would be the Embeddable
(11:30:28 AM) sebersole: HibernateTypeDescription would be the Embedded
(11:30:57 AM) sebersole: much better to have HibernateTypeDescription on the attribute
(11:31:17 AM) sannegrinovero_ left the room (quit: Read error: Operation timed out).
(11:31:19 AM) gbadner: I'm not following "HibernateTypeDescription would be the Embedded"
(11:31:34 AM) sebersole: @Embeddable class Address
(11:31:55 AM) sebersole: well, sec
(11:32:09 AM) sebersole: let me see what you've done with HibernateTypeDescription
(11:32:34 AM) sebersole: right
(11:32:35 AM) sebersole: so
(11:32:44 AM) sebersole: HibernateTypeDescription resolves to one org.hibernate.Type
(11:32:49 AM) sebersole: HibernateTypeDescription resolves to one org.hibernate.type.Type
(11:33:07 AM) sebersole: which for composites is one usage of that composiet class
(11:33:21 AM) sebersole: NOT THE composite class itself
(11:33:45 AM) sebersole: so going back to that example
(11:33:48 AM) sebersole: @Embeddable class Address
(11:34:15 AM) sebersole: there are 2 org.hibernate.type.Type instances related to that when we have:
(11:34:33 AM) sebersole: @Embedded Address homeAddress, workAddress;
(11:36:09 AM) emmanuel is now known as emmanuel_off
(11:36:28 AM) gbadner: and they refer to the same Class (or should refer to the same JavaType)
(11:36:49 AM) sebersole: HibernateTypeDescriptor != java class
(11:36:59 AM) gbadner: yes, I know;
(11:37:00 AM) sebersole: HibernateTypeDescription == org.hibernate.type.Type
(11:37:04 AM) gbadner: yep
(11:37:36 AM) sebersole: so how would the JavaType for Address report getHibernateTypeDescriptor() ?
(11:37:47 AM) sebersole: when there are more than one
(11:38:10 AM) gbadner: I'm not saying that there would be JavaType.getHibernateTypeDescriptor
(11:38:11 AM) gbadner: ()
(11:38:24 AM) sebersole: [13:27] <gbadner> it would be really nice if o.h.metamodel.spi.Type encapsulated HibernateTypeDescription
(11:38:29 AM) sebersole: i'm just answering that ^^
(11:38:46 AM) gbadner: o.h.metamodel.spi.Type != o.h.metamodel.spi.JavaType
(11:39:08 AM) sebersole: well
(11:39:09 AM) gbadner: it seems we could have o.h.metamodel.spi.Type.getHibernateTypeDescriptor()
(11:39:18 AM) sebersole: o.h.metamodel.spi.Type
(11:39:21 AM) sebersole: does not exist
(11:39:28 AM) sebersole: aside from (i assume) on your computer
(11:39:36 AM) sebersole: whcih as i keep telling you i cannot see
(11:39:44 AM) gbadner: is that gone now?
(11:40:03 AM) sebersole: i guess you mean the domain package?
(11:40:18 AM) gbadner: right, sorry, domain package
(11:40:24 AM) sebersole: which again cannot work
(11:41:06 AM) sebersole: unless attribute(homeAddress).getType() and attribute(workAddress).getType() return different objects
(11:41:36 AM) gbadner: I would think that they would
(11:41:52 AM) sebersole: depends
(11:42:04 AM) sebersole: it makes senes in regards to build a type
(11:42:06 AM) sebersole: but
(11:42:34 AM) sebersole: then you are sayign that org.hibernate.metamodel.spi.domain.Type corresponds to a org.hibernate.type.Type
(11:42:44 AM) sebersole: which opens up a whole new can of works
(11:42:46 AM) sebersole: worms
(11:42:56 AM) sebersole: because entity has a similar issue
(11:43:23 AM) gbadner: wimi, it would be nice if we had org.hibernate.metamodel.spi.domain.Type.getHibernateTypeDescription()
(11:43:23 AM) sebersole: its type versus the type of any of the *ToOnes that target it
(11:43:36 AM) sebersole: i understand that
(11:43:43 AM) sebersole: and i am saying its actually not very nice
(11:44:08 AM) gbadner: ok, I'm not getting where the problem is
(11:44:15 AM) sebersole: unless Type is duplicated to correspond to o.h.type.Type
(11:44:26 AM) sebersole: well i explained it above
(11:45:36 AM) sebersole: the o.h.type.Type for @Entity User is not the same as the o.h.type.Type for @ManyToOne User getUser()
(11:45:53 AM) sebersole: domain is meant to model something different
(11:46:05 AM) sebersole: it is mean to model, oddly, the users domain
(11:46:16 AM) gbadner: ok, I get it
(11:46:19 AM) sebersole: its a Class-less view of their java classes
(11:46:43 AM) sebersole: sort of like ClassInfo from jandex, except it has attributes, etc
(11:46:47 AM) gbadner: for an association, it is actually the same domain object
(11:47:02 AM) gbadner: ok, I forgot about that
(11:47:19 AM) sebersole: for an association, attribute.getType() points to the associated type *instance* yes
(11:47:50 AM) sebersole: again, its like the reflection package
(11:48:01 AM) sebersole: but not needing real classes
(11:48:07 AM) gbadner: right; got it
(11:51:04 AM) gbadner: btw, I decided a NULL_JAVA_TYPE was a bad idea
(11:51:39 AM) sebersole: ok, btw, this is why too i was saying that it would be nice to tie this all in with org.hibernate.metamodel.spi.domain.Type
(11:51:50 AM) sebersole: it would all just flow
(11:52:11 AM) sebersole: HibernateTypeDescriptor could even reference the org.hibernate.metamodel.spi.domain.Type
(11:52:18 AM) gbadner: I did change o.h.metamodel.spi.domain.Type to have a JavaType
(11:52:39 AM) sebersole: yeah i mentioned i did nto like that
(11:52:45 AM) sebersole: getType().getType()
(11:52:58 AM) sebersole: and you can spin it in any terms you like :)
(11:53:02 AM) gbadner: well, it could have it internally; it does not have to be exposed
(11:53:13 AM) sebersole: it still boils down to getType().getType()
(11:53:25 AM) sebersole: meh
(11:53:31 AM) sebersole: if it buys you something i guess..
(11:53:33 AM) gbadner: I would go back to Type.getClassName() and getClassReference()
(11:53:50 AM) sebersole: i mean really thats what JavaType was
(11:54:02 AM) sebersole: like i said, i think i moved away from JavaType to that model
(11:54:06 AM) sebersole: for just this reason
(11:55:25 AM) gbadner: before my changes there is:
(11:55:45 AM) gbadner: public Class<?> getClassReference();
(11:55:45 AM) gbadner: public ValueHolder<Class<?>> getClassReferenceUnresolved();
(11:56:51 AM) gbadner: I replace those locally to just have:
(11:57:00 AM) gbadner: JavaType getJavaType();
(11:57:19 AM) sebersole: yes, on Type
(11:57:27 AM) sebersole: which is a java type
(11:57:41 AM) sebersole: not sure what i'm missing
(11:58:28 AM) sebersole: so you now have call chains like this right? :
(11:58:38 AM) sebersole: attribute.getType().getJavaType()
(11:58:40 AM) gbadner: yes
(11:58:49 AM) sebersole: i mean thats utterly redundant imo
(11:59:00 AM) sebersole: type is a type
(11:59:25 AM) gbadner: I have no problem just encapsulating JavaType w/in Type
(11:59:39 AM) gbadner: and delegating
(12:00:40 PM) sebersole: i'm not sure what you think JavaType is bringing to the table here
(12:00:41 PM) gbadner: should getClassReferenceUnresolved() still return a ValueHolder, or a JavaType?
(12:01:33 PM) sebersole: oh, maybe i see your thinking
(12:01:46 PM) gbadner: also, there are places that both values are passed as arguments
(12:01:49 PM) sebersole: you think JavaType is a standin for java.lang.Class
(12:01:51 PM) gbadner: and that seems goofy
(12:02:03 PM) sebersole: both what values?
(12:02:12 PM) gbadner: sec, I'll find an example
(12:04:07 PM) gbadner: sebersole, https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/Entity.java#L43
(12:04:28 PM) gbadner: passes both className and classReference
(12:04:52 PM) gbadner: there are a bunch of places like that, and it seems it would be more concise to pass JavaType
(12:05:46 PM) gbadner: I replaced a lot of stuff like that with JavaType, but I'm hesitant to push if you don't buy into it
(12:07:17 PM) sebersole: gbadner: like i said...
(12:07:23 PM) sebersole: [13:59] <sebersole> oh, maybe i see your thinking
(12:07:27 PM) sebersole: [14:00] <sebersole> you think JavaType is a standin for java.lang.Class
(12:07:34 PM) gbadner: yes
(12:07:54 PM) sebersole: really for you locally JavaType is a rerence to the java Class using delayed access
(12:08:01 PM) sebersole: so then please name it that ;)
(12:08:18 PM) sebersole: i *hate* seeing silliness like type.getType()
(12:08:25 PM) gbadner: delayedJavaType?
(12:08:37 PM) sebersole: JavaClassReferebce
(12:09:02 PM) gbadner: ok, so change JavaType to JavaClassReference
(12:09:02 PM) sebersole: JavaClassReference type.getJavaClassReference()
(12:09:09 PM) sebersole: right
(12:09:11 PM) gbadner: ok
(12:09:22 PM) sebersole: or something like that more descriptive of how you are using it
(12:09:37 PM) gbadner: ok, that's fine with me
(12:11:44 PM) gbadner: sebersole, there is a constructor JavaType(Class<?> clazz); we were thinking that if the class had already been loaded, that we would want to just use it, but now it sounds like that's not true
(12:12:26 PM) gbadner: hardy and I were (wrongly) thinking that the classes would already be loaded for annotations source
(12:13:06 PM) sebersole: phone
(12:13:08 PM) gbadner: k
(12:14:08 PM) sebersole: again there are times when it is completely safe to use Class
(12:14:28 PM) sebersole: e.g. we arent going to be enhancing Integer
(12:14:35 PM) gbadner: right
(12:15:25 PM) sebersole: so both forms of ctor are fine and needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment