Search Results

Search found 955 results on 39 pages for 'jpa'.

Page 10/39 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • JPA 2.0 EclipseLink Check for unique

    - by Parhs
    Hello... I have a collumn as unique=true.. in Exam class.... I found that because transactions are commited automaticaly so to force the commit i use em.commit() However i would like to know how to check if it is unique.Running a query isnt a solution because it may be an instert after checking because of the concurency.... Which is the best way to check for uniqness? List<Exam_Normal> exam_normals = exam.getExam_Normal(); exam.setExam_Normal(null); try { em.persist(exam); em.flush(); Long i = 0L; if (exam_normals != null) { for (Exam_Normal e_n : exam_normals) { i++; e_n.setItem(i); e_n.setId(exam); em.persist(e_n); } } } catch (Exception e) { System.out.print("sfalma--"); } } d

    Read the article

  • Deleting JPA entity containing @CollectionOfElements throws ConstraintViolationException

    - by Lyle
    I'm trying to delete entities which contain lists of Integer, and I'm getting ConstraintViolationExceptions because of the foreign key on the table generated to hold the integers. It appears that the delete isn't cascading to the mapped collection. I've done quite a bit of searching, but all of the examples I've seen on how to accomplish this are in reference to a mapped collection of other entities which can be annotated; here I'm just storing a list of Integer. Here is the relevant excerpt from the class I'm storing: @Entity @Table(name="CHANGE_IDS") @GenericGenerator( name = "CHANGE_ID_GEN", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = { @Parameter(name="sequence_name", value="course_changes_seq"), @Parameter(name="increment_size", value="5000"), @Parameter(name=" optimizer", value="pooled") } ) @NamedQueries ({ @NamedQuery( name="Changes.getByStatus", query= "SELECT c " + "FROM DChanges c " + "WHERE c.status = :status "), @NamedQuery( name="Changes.deleteByStatus", query= "DELETE " + "FROM Changes c " + "WHERE c.status = :status ") }) public class Changes { @Id @GeneratedValue(generator="CHANGE_ID_GEN") @Column(name = "ID") private final long id; @Enumerated(EnumType.STRING) @Column(name = "STATUS", length = 20, nullable = false) private final Status status; @Column(name="DOC_ID") @org.hibernate.annotations.CollectionOfElements @org.hibernate.annotations.IndexColumn(name="DOC_ID_ORDER") private List<Integer> docIds; } I'm deleting the Changes objects using a @NamedQuery: final Query deleteQuery = this.entityManager.createNamedQuery("Changes.deleteByStatus"); deleteQuery.setParameter("status", Status.POST_FLIP); final int deleted = deleteQuery.executeUpdate(); this.logger.info("Deleted " + deleted + " POST_FLIP Changes");

    Read the article

  • Compare two dates with JPA

    - by Kiva
    Hello everybody, I need to compare two dates in a JPQL query but it doesn't work. Here is my query: Query query = em.createQuery("SELECT h FROM PositionHistoric h, SeoDate d WHERE h.primaryKey.siteDb = :site AND h.primaryKey.engineDb = :engine AND h.primaryKey.keywordDb = :keyword AND h.date = d AND d.date <= :date ORDER BY h.date DESC"); My parameter date is a java.util.Date My query return a objects list but the dates are upper and lower to my parameter. Someone kown how to do this ? Thanks.

    Read the article

  • JPA entities -- org.hibernate.TypeMismatchException

    - by shane lee
    Environment: JDK 1.6, JEE5 Hibernate Core 3.3.1.GA, Hibernate Annotations 3.4.0.GA DB:Informix Used reverse engineering to create my persistence entities from db schema [NB:This is a schema in work i cannot change] Getting exception when selecting list of basic_auth_accounts org.hibernate.TypeMismatchException: Provided id of the wrong type for class ebusiness.weblogic.model.UserAccounts. Expected: class ebusiness.weblogic.model.UserAccountsId, got class ebusiness.weblogic.model.BasicAuthAccountsId Both basic_auth_accounts and user_accounts have composite primary keys and one-to-one relationships. Any clues what to do here? This is pretty important that i get this to work. Cannot find any substantial solution on the net, some say to create an ID class which hibernate has done, and some say not to have a one-to-one relationship. Please help me!! /** * BasicAuthAccounts generated by hbm2java */ @Entity @Table(name = "basic_auth_accounts", schema = "ebusdevt", catalog = "ebusiness_dev", uniqueConstraints = @UniqueConstraint(columnNames = { "realm_type_id", "realm_qualifier", "account_name" })) public class BasicAuthAccounts implements java.io.Serializable { private BasicAuthAccountsId id; private UserAccounts userAccounts; private String accountName; private String hashedPassword; private boolean passwdChangeReqd; private String hashMethodId; private int failedAttemptNo; private Date failedAttemptDate; private Date lastAccess; public BasicAuthAccounts() { } public BasicAuthAccounts(UserAccounts userAccounts, String accountName, String hashedPassword, boolean passwdChangeReqd, String hashMethodId, int failedAttemptNo) { this.userAccounts = userAccounts; this.accountName = accountName; this.hashedPassword = hashedPassword; this.passwdChangeReqd = passwdChangeReqd; this.hashMethodId = hashMethodId; this.failedAttemptNo = failedAttemptNo; } public BasicAuthAccounts(UserAccounts userAccounts, String accountName, String hashedPassword, boolean passwdChangeReqd, String hashMethodId, int failedAttemptNo, Date failedAttemptDate, Date lastAccess) { this.userAccounts = userAccounts; this.accountName = accountName; this.hashedPassword = hashedPassword; this.passwdChangeReqd = passwdChangeReqd; this.hashMethodId = hashMethodId; this.failedAttemptNo = failedAttemptNo; this.failedAttemptDate = failedAttemptDate; this.lastAccess = lastAccess; } @EmbeddedId @AttributeOverrides( { @AttributeOverride(name = "realmTypeId", column = @Column(name = "realm_type_id", nullable = false, length = 32)), @AttributeOverride(name = "realmQualifier", column = @Column(name = "realm_qualifier", nullable = false, length = 32)), @AttributeOverride(name = "accountId", column = @Column(name = "account_id", nullable = false)) }) public BasicAuthAccountsId getId() { return this.id; } public void setId(BasicAuthAccountsId id) { this.id = id; } @OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn @NotNull public UserAccounts getUserAccounts() { return this.userAccounts; } public void setUserAccounts(UserAccounts userAccounts) { this.userAccounts = userAccounts; } /** * BasicAuthAccountsId generated by hbm2java */ @Embeddable public class BasicAuthAccountsId implements java.io.Serializable { private String realmTypeId; private String realmQualifier; private long accountId; public BasicAuthAccountsId() { } public BasicAuthAccountsId(String realmTypeId, String realmQualifier, long accountId) { this.realmTypeId = realmTypeId; this.realmQualifier = realmQualifier; this.accountId = accountId; } /** * UserAccounts generated by hbm2java */ @Entity @Table(name = "user_accounts", schema = "ebusdevt", catalog = "ebusiness_dev") public class UserAccounts implements java.io.Serializable { private UserAccountsId id; private Realms realms; private UserDetails userDetails; private Integer accessLevel; private String status; private boolean isEdge; private String role; private boolean chargesAccess; private Date createdTimestamp; private Date lastStatusChangeTimestamp; private BasicAuthAccounts basicAuthAccounts; private Set<Sessions> sessionses = new HashSet<Sessions>(0); private Set<AccountGroups> accountGroupses = new HashSet<AccountGroups>(0); private Set<UserPrivileges> userPrivilegeses = new HashSet<UserPrivileges>(0); public UserAccounts() { } public UserAccounts(UserAccountsId id, Realms realms, UserDetails userDetails, String status, boolean isEdge, boolean chargesAccess) { this.id = id; this.realms = realms; this.userDetails = userDetails; this.status = status; this.isEdge = isEdge; this.chargesAccess = chargesAccess; } @EmbeddedId @AttributeOverrides( { @AttributeOverride(name = "realmTypeId", column = @Column(name = "realm_type_id", nullable = false, length = 32)), @AttributeOverride(name = "realmQualifier", column = @Column(name = "realm_qualifier", nullable = false, length = 32)), @AttributeOverride(name = "accountId", column = @Column(name = "account_id", nullable = false)) }) @NotNull public UserAccountsId getId() { return this.id; } public void setId(UserAccountsId id) { this.id = id; } @OneToOne(fetch = FetchType.LAZY, mappedBy = "userAccounts") public BasicAuthAccounts getBasicAuthAccounts() { return this.basicAuthAccounts; } public void setBasicAuthAccounts(BasicAuthAccounts basicAuthAccounts) { this.basicAuthAccounts = basicAuthAccounts; } /** * UserAccountsId generated by hbm2java */ @Embeddable public class UserAccountsId implements java.io.Serializable { private String realmTypeId; private String realmQualifier; private long accountId; public UserAccountsId() { } public UserAccountsId(String realmTypeId, String realmQualifier, long accountId) { this.realmTypeId = realmTypeId; this.realmQualifier = realmQualifier; this.accountId = accountId; } @Column(name = "realm_type_id", nullable = false, length = 32) @NotNull @Length(max = 32) public String getRealmTypeId() { return this.realmTypeId; } public void setRealmTypeId(String realmTypeId) { this.realmTypeId = realmTypeId; } @Column(name = "realm_qualifier", nullable = false, length = 32) @NotNull @Length(max = 32) public String getRealmQualifier() { return this.realmQualifier; } public void setRealmQualifier(String realmQualifier) { this.realmQualifier = realmQualifier; } @Column(name = "account_id", nullable = false) public long getAccountId() { return this.accountId; } public void setAccountId(long accountId) { this.accountId = accountId; } Main Code for classes are:

    Read the article

  • Storing Objects in columns using Hibernate JPA

    - by user210791
    Is it possible to store something like the following using only one table? Right now, what hibernate will do is create two tables, one for Families and one for people. I would like for the familymembers object to be serialized into the column in the database. @Entity(name = "family") class Family{ private final List<Person> familyMembers; } class Person{ String firstName, lastName; int age; }

    Read the article

  • jpa IllegalArgumentException exception

    - by Bunny Rabbit
    i've three entity classes in my project public class Blobx { @ManyToOne private Userx user; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; } public class Index { @Id private String keyword; @OneToMany(cascade = CascadeType.PERSIST) private List<Blobx> blobs; } public class Userx { @Id private String name; @OneToMany(mappedBy = "user") private List<Blobx>blobs; } while running the following lines app engine throws an exception em.getTransaction().begin(); em.persist(index); em.getTransaction().commit();//exception is thrown em.close(); as Caused by: java.lang.IllegalArgumentException: can't operate on multiple entity groups in a single transaction. found both Element { type: "Index" name: "function" } and Element { type: "Userx" name: "18580476422013912411" } i can't understand what's wrong?

    Read the article

  • Tomcat 6, JPA and Data sources

    - by asrijaal
    Hi there, I'm trying to get a data source working in my jsf app. I defined the data source in my web-apps context.xml webapp/META-INF/context.xml <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/Sale"> <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="Sale" password="admin" type="javax.sql.DataSource" url="jdbc:mysql://localhost/sale" username="admin"/> </Context> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>faces/welcomeJSF.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>ruby</param-value> </context-param> </web-app> and my persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" 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_1_0.xsd"> <persistence-unit name="SalePU" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <non-jta-data-source>Sale</non-jta-data-source> <class>org.comp.sale.AnfrageAnhang</class> <class>org.comp.sale.Beschaffung</class> <class>org.comp.sale.Konto</class> <class>org.comp.sale.Anfrage</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit> </persistence> But no data source seems to be created by Tomcat, I only get this exception Exception [TOPLINK-7060] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException Exception Description: Cannot acquire data source [Sale]. Internal Exception: javax.naming.NameNotFoundException: Name Sale is not bound in this Context The needed jars for the MySQL driver are included into the WEB-INF/lib dir. What I'm doing wrong?

    Read the article

  • Tips for resolving Hibernate/JPA EntityNotFoundException

    - by Damo
    I'm running into a problem with Hibernate where when trying to delete a group of Entities I encounter the following error: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.locuslive.odyssey.entity.FreightInvoiceLine#<null>] These are not normally so difficult to track down as they are usually caused by an entity being deleted but not being removed from a Collection that it is a member of. In this case I have removed the entity from every list that I can think of (it's a complex datamodel). I've put JBoss logging into Trace and I can see the collections that are being cascaded. However I can't seem to find the Collection containing the entity that I'm deleting. Does anyone have any tips for resolving this particular Exception? Thanks.

    Read the article

  • JPA + Hibernate + Named Query + how to JOIN a subquery result

    - by Srihari
    Can anybody help me in converting the following native query into a Named Query? Native Query: SELECT usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id, term.term_name, count(material.material_id) as "Total Book Count", fpc.FOLLETT_PENDING_COUNT as "Follett Pending Count", rrc.RESOLUTION_REQUIRED_COUNT as "Resolution Required Count" FROM va_school sch JOIN va_user_school_rel usr1 on sch.school_id=usr1.school_id JOIN va_user_role_rel urr1 on usr1.user_id=urr1.user_id and urr1.role_id=1001 JOIN va_user_school_rel usr2 on sch.school_id=usr2.school_id JOIN va_user_role_rel urr2 on usr2.user_id=urr2.user_id and urr2.role_id=1002 JOIN va_term term on term.school_id = usr1.school_id JOIN va_class course on course.term_id = term.term_id JOIN va_material material on material.class_id = course.class_id LEFT JOIN (SELECT VA_CLASS.TERM_ID as "TERM_ID", COUNT(*) as "FOLLETT_PENDING_COUNT" FROM VA_CLASS JOIN VA_MATERIAL ON VA_MATERIAL.CLASS_ID = VA_CLASS.CLASS_ID WHERE VA_CLASS.reference_flag = 'A' AND trunc(VA_MATERIAL.FOLLETT_STATUS) = 0 GROUP BY VA_CLASS.TERM_ID) fpc on term.term_id = fpc.term_id LEFT JOIN (SELECT VA_CLASS.TERM_ID as "TERM_ID", COUNT(*) as "RESOLUTION_REQUIRED_COUNT" FROM VA_CLASS JOIN VA_MATERIAL ON VA_MATERIAL.CLASS_ID = VA_CLASS.CLASS_ID WHERE VA_CLASS.reference_flag = 'A' AND trunc(VA_MATERIAL.FOLLETT_STATUS) = 1 GROUP BY VA_CLASS.TERM_ID) rrc on term.term_id = rrc.term_id WHERE course.reference_flag = 'A' GROUP BY usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id, term.term_name, fpc.FOLLETT_PENDING_COUNT, rrc.RESOLUTION_REQUIRED_COUNT ORDER BY usr1.school_id, term.term_name; Thanks in advance. Srihari

    Read the article

  • JPA ManyToMany referencing issue

    - by dharga
    I have three tables. AvailableOptions and PlanTypeRef with a ManyToMany association table called AvailOptionPlanTypeAssoc. The trimmed down schemas look like this CREATE TABLE [dbo].[AvailableOptions]( [SourceApplication] [char](8) NOT NULL, [OptionId] [int] IDENTITY(1,1) NOT NULL, ... ) CREATE TABLE [dbo].[AvailOptionPlanTypeAssoc]( [SourceApplication] [char](8) NOT NULL, [OptionId] [int] NOT NULL, [PlanTypeCd] [char](2) NOT NULL, ) CREATE TABLE [dbo].[PlanTypeRef]( [PlanTypeCd] [char](2) NOT NULL, [PlanTypeDesc] [varchar](32) NOT NULL, ) And the Java code looks like this. //AvailableOption.java @ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER) @JoinTable( name = "AvailOptionPlanTypeAssoc", joinColumns = { @JoinColumn(name = "OptionId"), @JoinColumn(name="SourceApplication")}, inverseJoinColumns=@JoinColumn(name="PlanTypeCd")) List<PlanType> planTypes = new ArrayList<PlanType>(); //PlanType.java @ManyToMany @JoinTable( name = "AvailOptionPlanTypeAssoc", joinColumns = { @JoinColumn(name = "PlanTypeCd")}, inverseJoinColumns={@JoinColumn(name="OptionId"), @JoinColumn(name="SourceApplication")}) List<AvailableOption> options = new ArrayList<AvailableOption>(); The problem arises when making a select on AvailableOptions it joins back onto itself. Note the following SQL code from the backtrace. The second inner join should be on PlanTypeRef. SELECT t0.OptionId, t0.SourceApplication, t2.PlanTypeCd, t2.EffectiveDate, t2.PlanTypeDesc, t2.SysLstTrxDtm, t2.SysLstUpdtUserId, t2.TermDate FROM dbo.AvailableOptions t0 INNER JOIN dbo.AvailOptionPlanTypeAssoc t1 ON t0.OptionId = t1.OptionId AND t0.SourceApplication = t1.SourceApplication INNER JOIN dbo.AvailableOptions t2 ON t1.PlanTypeCd = t2.PlanTypeCd WHERE (t0.SourceApplication = ? AND t0.OptionType = ?) ORDER BY t0.OptionId ASC, t0.SourceApplication ASC [params=(String) testApp, (String) junit0]}

    Read the article

  • A cycle in object graph detected in JPA.

    - by Nitesh Panchal
    Hello, I am trying to figure out this error since 5 hours without any success. SO i finally thought of posting in here. Please help i am really in big trouble. I am stuck on this and see no way of solving this error. This is my database structure tblBlogRegion BlogRegionId (primary key) BlogRegionName tblGadget GadgetId(primary key) GadgetName tblBlogs BlogId(primary key) Blogname BlogTypeId (reference key from tblSiteTerm tblSiteTerms SiteTermsId(primary key) SiteTermsName tblBlogGadgets BlogGadgetsId(primary key) BlogRegionId(foreign key from tblBlogRegion) BlogId(foreign key from tblBlog) GadgetId(foreign key from tblGadget) Is it not normal database structure? Do you see anything that is cyclic? WHen i try to fetch list from tblGadgets i get this error :- [com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: entity.BlogGadgets[blogGadgetsId=1] -> entity.Blogs[blogId=2] -> entity.BlogGadgets[blogGadgetsId=1]] I am trying to get list from web service using JAS-WS.

    Read the article

  • JPA + Hibernate + Named Query + how to JOIN a subquery result

    - by Srihari
    Hi, Can anybody help me in converting the following native query into a Named Query? Native Query: SELECT usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id, term.term_name, count(material.material_id) as "Total Book Count", fpc.FOLLETT_PENDING_COUNT as "Follett Pending Count", rrc.RESOLUTION_REQUIRED_COUNT as "Resolution Required Count" FROM va_school sch JOIN va_user_school_rel usr1 on sch.school_id=usr1.school_id JOIN va_user_role_rel urr1 on usr1.user_id=urr1.user_id and urr1.role_id=1001 JOIN va_user_school_rel usr2 on sch.school_id=usr2.school_id JOIN va_user_role_rel urr2 on usr2.user_id=urr2.user_id and urr2.role_id=1002 JOIN va_term term on term.school_id = usr1.school_id JOIN va_class course on course.term_id = term.term_id JOIN va_material material on material.class_id = course.class_id LEFT JOIN (SELECT VA_CLASS.TERM_ID as "TERM_ID", COUNT(*) as "FOLLETT_PENDING_COUNT" FROM VA_CLASS JOIN VA_MATERIAL ON VA_MATERIAL.CLASS_ID = VA_CLASS.CLASS_ID WHERE VA_CLASS.reference_flag = 'A' AND trunc(VA_MATERIAL.FOLLETT_STATUS) = 0 GROUP BY VA_CLASS.TERM_ID) fpc on term.term_id = fpc.term_id LEFT JOIN (SELECT VA_CLASS.TERM_ID as "TERM_ID", COUNT(*) as "RESOLUTION_REQUIRED_COUNT" FROM VA_CLASS JOIN VA_MATERIAL ON VA_MATERIAL.CLASS_ID = VA_CLASS.CLASS_ID WHERE VA_CLASS.reference_flag = 'A' AND trunc(VA_MATERIAL.FOLLETT_STATUS) = 1 GROUP BY VA_CLASS.TERM_ID) rrc on term.term_id = rrc.term_id WHERE course.reference_flag = 'A' GROUP BY usr1.user_id, urr1.role_id, usr2.user_id, urr2.role_id, usr1.school_id, term.term_name, fpc.FOLLETT_PENDING_COUNT, rrc.RESOLUTION_REQUIRED_COUNT ORDER BY usr1.school_id, term.term_name; Thanks in advance. Srihari

    Read the article

  • PERSISTENCE LOB WITH JPA

    - by rfders
    Hi, Folks. I have this problem using JBOSS, EJB3 and MSSQL Express . i'm trying to persist an entity with an Blob attribute which was converted into a byte[], apparently it create the entity perfectly, no error was logged at jboss's console. but when i check into database the column is null. i already checked the Object to byte[] method and it is fine. i tried assigning Image and varbinary(Max) data type to this column. so i really don't know what it happening, why the column is not inserted into database. thanks a lot.

    Read the article

  • JPA @TableGenerator shared between multiple entities

    - by Mauricio
    Hi Guys, I have a 'dog' Entitiy with an @Id and a @TableGenerator ... @TableGenerator(table = "seq", name = "dog_gen", pkColumnName = "seq_name", valueColumnName="seq_val") @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog_gen") private Long id; ... Is there a way to reuse the same table generator (dog_gen) in other entity? I want to keep the same id sequence in two independent Entities, say dog=1, dog=2, dog=3, cat=4, cat=5, dog=6 and so on... Both entities don't share a common superclass to implement some kind of inheritance with the id property. If I add the @GeneratedValue( generator="dog_gen") on my cat entity, omitting the @TableGenerator declaration throws an Exception saying it can't find the generator when starting the context. Caused by: org.hibernate.AnnotationException: Unknown Id.generator: dog_gen at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:413) at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1795) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1229) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)

    Read the article

  • Duplicate column name by JPA with @ElementCollection and @Inheritance

    - by gerry
    I've created the following scenario: @javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class MyEntity implements Serializable{ @Id @GeneratedValue protected Long id; ... @ElementCollection @CollectionTable(name="ENTITY_PARAMS") @MapKeyColumn (name = "ENTITY_KEY") @Column(name = "ENTITY_VALUE") protected Map<String, String> parameters; ... } As well as: @javax.persistence.Entity public class Sensor extends MyEntity{ @Id @GeneratedValue protected Long id; ... // so here "protected Map<String, String> parameters;" is inherited !!!! ... } So running this example, no tables are created and i get the following message: WARNUNG: Got SQLException executing statement "CREATE TABLE ENTITY_PARAMS (Entity_ID BIGINT NOT NULL, ENTITY_VALUE VARCHAR(255), ENTITY_KEY VARCHAR(255), Sensor_ID BIGINT NOT NULL, ENTITY_VALUE VARCHAR(255))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'ENTITY_VALUE' I also tried overriding the attributes on the Sensor class... @AttributeOverrides({ @AttributeOverride(name = "ENTITY_KEY", column = @Column(name = "SENSOR_KEY")), @AttributeOverride(name = "ENTITY_VALUE", column = @Column(name = "SENSOR_VALUE")) }) ... but the same error. Can anybody help me?

    Read the article

  • How to backup database to disk using JPA?

    - by Nitesh Panchal
    Hello, Which query to write in JPQL for backing up database on disk? If in JPQL it's not available even native sql query will do. Also, i would like to bring one issue in front of stackoverflow developers :- This site doesn't properly work in Opera (Opera 9.63). Whenever i write question and click "Post Your question" The button click event doesn't fire at all, may be, the server side event doesn't fire or something. However, no such problem comes in IE and firefox.

    Read the article

  • Why is an oracle sequence named hibernate_sequence being created with JPA using Hibernate with the O

    - by JavaRocky
    All my entities use this type of @Id @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYENTITY_SEQ") @SequenceGenerator(name = "MYENTITY_SEQ", sequenceName = "MYENTITY_SEQ") @Column(name = "MYENTITY", nullable = false) private Long id; Or @Id @Column(name = "MYENTITY") I find that an oracle sequence named hibernate_sequence is always created. Why is this so? And how can i avoid this? I am using JPA1 with Hibernate 3 and the Oracle 10g dialect.

    Read the article

  • autocommit and @Transactional and Cascading with spring, jpa and hibernate

    - by subes
    Hi, what I would like to accomplish is the following: have autocommit enabled so per default all queries get commited if there is a @Transactional on a method, it overrides the autocommit and encloses all queries into a single transaction, thus overriding the autocommit if there is a @Transactional method that calls other @Transactional annotated methods, the outer most annotation should override the inner annotaions and create a larger transaction, thus annotations also override eachother I am currently still learning about spring-orm and couldn't find documentation about this and don't have a test project for this yet. So my questions are: What is the default behaviour of transactions in spring? If the default differs from my requirement, is there a way to configure my desired behaviour? Or is there a totally different best practice for transactions? --EDIT-- I have the following test-setup: @javax.persistence.Entity public class Entity { @Id @GeneratedValue private Integer id; private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } @Repository public class Dao { @PersistenceContext private EntityManager em; public void insert(Entity ent) { em.persist(ent); } @SuppressWarnings("unchecked") public List<Entity> selectAll() { List<Entity> ents = em.createQuery("select e from " + Entity.class.getName() + " e").getResultList(); return ents; } } If I have it like this, even with autocommit enabled in hibernate, the insert method does nothing. I have to add @Transactional to the insert or the method calling insert for it to work... Is there a way to make @Transactional completely optional?

    Read the article

  • JPA persistence.xml share same jar file

    - by user213855
    Hi! I'm wondering if I can share the same jar file for several persistence units.. I mean: I have two persistence units described in my persistence.xml file and the entities are not in the same JAR. Entities are in a separated JAR file but, in that one, there are entites for both persistence units. I think I red somewhere that I coould use tag something like this: externalEntities.jar#com.mycompany.EntityA so I could separate them. I tried this solution and it doesn't work. Now I guess that it couldn't be done to package all entities (for two different persistence units) in the same JAR file. What do yo think?

    Read the article

  • Provisioning api jpa

    - by user268515
    Hi i tried the following code Appsprovisioning.java public void calluser() throws AppsForYourDomainExceptiion IOException, { for(UserEntry userEntry : retrieveAllUsers().getEntries()) { m[x]= userEntry.getTitle().getPlainText(); x++; } try { for(int i=0;i<x;i++) { String sd=m[i]; stud greeting1 = new stud(sd); em.persist(greeting1); System.out.println("jk"); } } finally { em.close(); } public UserFeed retrieveAllUsers()throws ,ServiceException, IOException{ userService = new UserService("Myapplication"); userService.setUserCredentials("[email protected]","xxxxxxxx"); URL retrieveUrl = new URL("https://www.google.com/a/feeds/montfortperungudi.edu.in/user/2.0/"); UserFeed allUsers = new UserFeed(); UserFeed currentPage; Link nextLink; do { currentPage = userService.getFeed(retrieveUrl, UserFeed.class); allUsers.getEntries().addAll(currentPage.getEntries()); nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM); if (nextLink != null) { retrieveUrl = new URL(nextLink.getHref()); } } while (nextLink != null); return allUsers; } } Servlet.java public class servlet extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(servlet.class.getName()); // EntityManager em=null; AppsProvisioning aa=new AppsProvisioning(); public void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException { //em = EMFService.get().createEntityManager(); try { aa.calluser(); }catch(Exception e){ System.out.println("SEF "+e);} finally { // em.clear(); // em.close(); } } } Table Creation import javax.persistence.Entity; import javax.persistence.Id; @Entity(name="stud") public class stud { @Id private String fathername; public stud(String fathername) {// TODO Auto-generated constructor stub this.fathername=fathername; } public void setFathername(String fathername) { this.fathername = fathername; } public String getFathername() { return fathername; } } I cant able to store all the users in the table.. Its returning Session out error.

    Read the article

  • JPA - Performance with using multiple entity manager

    - by Nguyen Tuan Linh
    My situation is: The code is not mine I have two kinds of database: one is Dad, one is Son. In Dad, I have a table to store JNDI name. I will look up Dad using JNDI, create entity manager, and retrieve this table. From these retrieved JNDI names, I will create multiple entity managers using multiple Son databases. The problem is: Son have thousands of entities. It takes each Son database around 10 minutes to load all entities. If there is 4 Son databases, it will be 40 minutes. My question: Is there any way to load all entities and use them for all entity manager? Please look at the code below For each Son JNDI: Map<String, String> puSonProperties = new HashMap<String, String>(); puSonProperties.put("javax.persistence.jtaDataSource", sonJndi); EntityManagerFactory emf = Persistence.createEntityManagerFactory("PUSon", puSonProperties); PUSon - All of them use the same persistence unit log.info("Verify entity manager for son: {0} - {1}", sonCode, emSon.find(Son_configuration.class, 0) != null ? "ok" : "failed!"); This is the actual code where the loading of all entities begins. 10 mins.

    Read the article

  • can't persist jpa entity in app engine

    - by Bunny Rabbit
    public class Blobx { private String name; private BlobKey blobKey; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; //getters and setters } public class Userx { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; private String name; @OneToMany private List<Blobx> blobs; //getters and setters } while persiting the above Userx entity object i am encountering java.lang.IllegalStateException: Field "entities.Userx.blobs" contains a persistable object that isnt persistent, but the field doesnt allow cascade-persist!

    Read the article

  • Inheritance concept in jpa

    - by megala
    I created one table using Inheritance concept to sore data into google app engine datastore. It contained following coding but it shows error.How to user Inheritance concept.What error in my program Program 1: @Entity @Inheritance(strategy=InheritanceType.JOINED) public class calender { @Id private String EmailId; @Basic private String CalName; @Basic public void setEmailId(String emailId) { EmailId = emailId; } public String getEmailId() { return EmailId; } public void setCalName(String calName) { CalName = calName; } public String getCalName() { return CalName; } public calender(String EmailId,String CalName) { this.EmailId=EmailId; this.CalName=CalName; } } program 2: @Entity public class method { @Id private String method; public void setMethod(String method) { this.method = method; } public String getMethod() { return method; } public method(String method) { this.method=method; } } My constraint is I want ouput like this Calendertable coantain Emailid calenername and method table contain Emailid method How to achive this? thanks inadvance.

    Read the article

  • JPA @ManyToMany on only one side?

    - by Ethan Leroy
    I am trying to refresh the @ManyToMany relation but it gets cleared instead... My Project class looks like this: @Entity public class Project { ... @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "PROJECT_USER", joinColumns = @JoinColumn(name = "PROJECT_ID", referencedColumnName = "ID"), inverseJoinColumns = @JoinColumn(name = "USER_ID", referencedColumnName = "ID")) private Collection<User> users; ... } But I don't have - and I don't want - the collection of Projects in the User entity. When I look at the generated database tables, they look good. They contain all columns and constraints (primary/foreign keys). But when I persist a Project that has a list of Users (and the users are still in the database), the mapping table doesn't get updated gets updated but when I refresh the project afterwards, the list of Users is cleared. For better understanding: Project project = ...; // new project with users that are available in the db System.out.println(project getUsers().size()); // prints 5 em.persist(project); System.out.println(project getUsers().size()); // prints 5 em.refresh(project); System.out.println(project getUsers().size()); // prints 0 So, how can I refresh the relation between User and Project?

    Read the article

  • [hibernate - jpa] @CollectionOfElements without create the apposite table

    - by blow
    Hi all. I have this: Municipality class @Entity public class Municipality implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private String country; private String province; private String name; @Column(name="cod_catasto") private String codCatastale; private String cap; @CollectionOfElements private List<Address> addressList; public Municipality() { } ... Address class @Embeddable public class Address implements Serializable { @ManyToOne(fetch=FetchType.LAZY) @Cascade(CascadeType.SAVE_UPDATE) private Municipality municipality; @Column(length=45) private String address; public Address() { } ... Address is embedded in another class Person. When i save an instance of Person, hibernate create 3 tables: PERSON, MUNICIPALITY and MUNICIPALITY_ADDRESSLIST. MUNICIPALITY_ADDRESSLIST contains 2 fields: MUNICIPALITY_ID (FK) and STREET. I don't want this table, i only want the ID of table MUNICIPALITY into table PERSON(that embeds Address), what should i do? I tried to add @JoinTable in Municipality entity like this: @CollectionOfElements @JoinTable(name="person") private List<Address> addressList; It partially worked, but i cant choose the column name of table PERSON that contains ID of the table MUNICIPALITY, it is, by hibernate choose, simply "MUNICIPALITY_ID"... Thbaks.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >