Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name = "MyEntity")
- @org.hibernate.annotations.Table(appliesTo = "MyEntity")
- public class MyEntity
- {
- @Enumerated(value = javax.persistence.EnumType.STRING)
- @Transient
- @Formula(value = "select e.state from OTHER_ENTITY e")
- private State state;
- public State getState()
- {
- return this.state;
- }
- //setter and another properties
- }
- <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
- version="2.0">
- <persistence-unit name="myPersistence" transaction-type="RESOURCE_LOCAL">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <mapping-file>META-INF/orm.xml</mapping-file>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
- <properties>
- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
- <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
- <property name="hibernate.connection.url" value="jdbc:mysql://url:3306/db" />
- <property name="hibernate.connection.username" value="root" />
- <property name="hibernate.connection.password" value="root" />
- <property name="hibernate.show_sql" value="true" />
- <property name="hibernate.hbm2ddl.auto" value="validate" />
- </properties>
- </persistence-unit>
- @Entity
- @Table(name = "MyEntity")
- @org.hibernate.annotations.Table(appliesTo = "MyEntity")
- public class MyEntity
- {
- // MAYBE YOU HAVE TO MOVE IT TO THE GETTER @Enumerated(value = javax.persistence.EnumType.STRING)
- // REMOVE THIS @Transient
- private State state;
- @Enumerated(value = javax.persistence.EnumType.STRING) // MOVED
- @Formula(value = "(select e.state from OtheEntity e)")
- public State getState()
- {
- return this.state;
- }
- //setter and another properties
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement