metamodel

如何自动生成JPA元模型对象(1)—hibernate元模型生成器

五迷三道 提交于 2019-12-04 21:27:17
Hibernate静态元模型生成器既可以通过命令行使用,也可以集成在IDE中使用。大多数情况下,如果使用了jdk6及以上的版本,并且注解处理器的jar已经被包含在classpath中,注解处理器会自动的运行,因为Hibernate静态元模型生成器的jar包的META-INF/services目录里已经包含了文件javax.annotation.processing.Processor。 1.通过命令行使用(maven) 在maven构建的过程中,有几种方式可以运行注解处理器。其一,就是上面提到的在classpath中引入它的jar包。如果在classpath中有多个注解处理器,可以在maven的编译插件中传入处理选项参数 <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> <compilerArguments> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </compilerArguments> </configuration> </plugin> 使用maven-compiler

Rails custom meta model?

丶灬走出姿态 提交于 2019-12-04 15:02:48
I'd like to be able to add "meta" information to a model, basically user-defined fields. So, for instance, let's imagine a User model: I define fields for first name, last name, age, gender. I would like users to be able to define some "meta information", basically to go in their profile page and share other information. So one user might want to add "hobbies", "occupation", and "hometown", and another might want to add "hobbies", and "education". So, I'd like to be able to have a standard view for this kind of stuff, so for instance in the view I might do something like (in HAML): - for item

Creating queries using Criteria API (JPA 2.0)

僤鯓⒐⒋嵵緔 提交于 2019-12-04 10:49:28
问题 I'm trying to create a query with the Criteria API from JPA 2.0, but I can't make it work. The problem is with the "between" conditional method. I read some documentation to know how I have to do it, but since I'm discovering JPA, I don't understand why it does not work. First, I can't see "creationDate" which should appear when I write "Transaction_." I thought it was maybe normal, since I read the metamodel was generated at runtime, so I tried to use 'Foo_.getDeclaredSingularAttribute(

Hibernate 5 发行组件下载

强颜欢笑 提交于 2019-12-03 12:47:51
Hibernate 项目小组提供了一系列发布组合(bundles),这些发布组合发布在 SourceForge 文件发布系统中。这些发布的包有 TGZ 和ZIP 格式。 每一个发布组合包含有 JAR 文件,文档,源代码和其他一些有用的内容。 你可以选择你需要的格式来下载 Hibernate 的发布版本,有关发布版本的列表,请参考 https://sourceforge.net/projects/hibernate/files/hibernate-orm/ 。发布版本的结构请参考下面的内容: lib/required/ 目录包含有 hibernate-core Jar 和所有需要的依赖。不管你需要使用 Hibernate 的何种功能,所有的这些都需要设置到你的 classpath 路径中。 lib/envers 目录包含有 hibernate-envers Jar 和需要的依赖(这些依赖,不包含在 lib/required/ 和lib/jpa/ 中)。 lib/spatial/ 目录包含有 hibernate-spatial Jar 和需要的依赖(这些依赖,不包含在 lib/required/ 和lib/jpa/ 中)。 lib/osgi/ 目录包含有 hibernate-osgi Jar 和需要的依赖(这些依赖,不包含在 lib/required/ 和lib/jpa/ 中)。

How to implement polymorphic JPA entities with generic relations

折月煮酒 提交于 2019-12-03 07:15:51
问题 I'm trying to use JPA 2.0 to create polymorphic entities with generic relations. There should be two tables, an event table and a notification table. Inside those table are concrete entities that are related to one another, like so: Event <---------- Notification<X extends Event> | | LoginEvent <------ LoginNotification extends Notification<LoginEvent> Logically this should be possible in hibernate, as it is possible in SQL: +----------+ +----------+ | Event | | Notif | +----------+ +--------

How to implement polymorphic JPA entities with generic relations

浪子不回头ぞ 提交于 2019-12-02 20:46:56
I'm trying to use JPA 2.0 to create polymorphic entities with generic relations. There should be two tables, an event table and a notification table. Inside those table are concrete entities that are related to one another, like so: Event <---------- Notification<X extends Event> | | LoginEvent <------ LoginNotification extends Notification<LoginEvent> Logically this should be possible in hibernate, as it is possible in SQL: +----------+ +----------+ | Event | | Notif | +----------+ +----------+ | | | Id | | Id | <- | Evt_id | | Type | <- | Type | | ... | | ... | +----------+ +----------+ This

MDA : Model Driven Architecture

孤街醉人 提交于 2019-12-01 12:57:38
Need a idea for developing very simple application demonstrating concepts of MDA. Alright, it is hard to find something analogous to a hello world in MDA world as MDA is geared on solving a bigger problem. The best way in my opinion to get started is to approach the below problem by "thinking in meta- model " In any real world application, there are certain artifacts that you require for any business entity to be persisted. Pick 2 such simple entities like Customer and Orders and generate all the corresponding artifacts across all the layers of any multi-tiered application (like ui,

JPA: How to perform a LIKE with a NUMBER column in a static JPA MetaModel?

依然范特西╮ 提交于 2019-12-01 06:08:20
问题 I do have a static metamodel with a NUMBER (actually, BigDecimal, don't ask why) column. Now I would like to do a LIKE query against that number column: CriteriaBuilder cb; cb.like(entity.get(Entity_.numbercol), "123%"); where entity.get(Entity_.numbercol) returns a Path<BigDecimal> . Naturally, I get a compile error: ...like(Expression<String>, ...) ... not applicable for the arguments (Path<BigDecimal>, ...) Casting the column with .as(String.class) fails due to some Bug in JPA, but I don't

Hibernate/JPA - NullPointerException when accessing SingularAttribute parameter

。_饼干妹妹 提交于 2019-12-01 03:38:49
I'm trying to use JPA2 type-safe criteria queries with Hibernate 5.0.7.Final. ... criteria.where( builder.equal( root.get(SingularAttribute.attr), value )); //where parameters are //criteria.where( builder.equal( root.get(Person_.name), "Can" )); ... The root.get always throw NullPointerException . The metamodel class Person_ for Person is generated by org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor . A similar problem was asked in JPA/Hibernate Static Metamodel Attributes not Populated -- NullPointerException but this time both classes are in the same package. Stack trace: java.lang

Hibernate/JPA - NullPointerException when accessing SingularAttribute parameter

泪湿孤枕 提交于 2019-12-01 00:36:14
问题 I'm trying to use JPA2 type-safe criteria queries with Hibernate 5.0.7.Final. ... criteria.where( builder.equal( root.get(SingularAttribute.attr), value )); //where parameters are //criteria.where( builder.equal( root.get(Person_.name), "Can" )); ... The root.get always throw NullPointerException . The metamodel class Person_ for Person is generated by org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor . A similar problem was asked in JPA/Hibernate Static Metamodel Attributes not Populated