2

have created my tables and relationships in the database PostgreSQL, but when I want to generate Hibernate Mapping Files and POJOs, they are not generated

I applied all the appropriate steps to hibernate.cfg.xml generation and hibernate.reveng.xml

I think it's because the name tables and fields that I have in all uppercase, because I tested with another BD with the names of the tables in lower case and if it works normally, I show the script of my tables.

CREATE TABLE "public"."T_LNEA"(
 "ID_LNEA" Integer NOT NULL,
 "ID_CTGRIA" Integer NOT NULL,
 "DSCRPCION" Character varying(200)
)
WITH (OIDS=FALSE)
;

ALTER TABLE "public"."T_LNEA" ADD CONSTRAINT "PK_ID_LNEA" PRIMARY KEY ("ID_LNEA")
;

CREATE TABLE "public"."T_SUB_LNEA"(
 "ID_SUB_LNEA" Integer NOT NULL,
 "ID_LNEA" Integer NOT NULL,
 "DSCRPCION" Character varying(200)
)
WITH (OIDS=FALSE)
;

-- Add keys for table public.T_SUB_LNEA

ALTER TABLE "public"."T_SUB_LNEA" ADD CONSTRAINT "PK_ID_SUB_LNEA" PRIMARY KEY ("ID_SUB_LNEA")
;

CREATE TABLE "public"."T_CTGRIA"(
 "ID_CTGRIA" Integer NOT NULL,
 "DSCRPCION" Character varying(200)
)
WITH (OIDS=FALSE)
;

ALTER TABLE "public"."T_CTGRIA" ADD CONSTRAINT "PK_ID_CRITERIA" PRIMARY KEY ("ID_CTGRIA")
;

And an image that is loading the tables using the JBOS Tools.

enter image description here

But still I need support because I can not generate the POJOs.

user2974805
  • 43
  • 1
  • 7

4 Answers4

4

In the File "hibernate.reveng.xml" has the following

  <schema-selection match-catalog="mybd" match-schema="mybd"/>

You have to delete the match-schema="mybd".

By default, when you use postgresql in hibernate, appears the match- schema , which does not happen in mysql , delete it and work , checked in Netbeans8.0

Tony Gomez
  • 41
  • 2
1

Hi, as said before, if I change the name of the table and its fields in lowercase, if generates POJOs, the question is why is not generated in capital letters .....

0

Une the reverse engineering tools provided by Hibernate. It depends on your IDE. For example with NetBeans this is how it is done: https://netbeans.org/kb/docs/web/hibernate-webapp.html

Hassen Ch.
  • 1,693
  • 18
  • 31
  • Hello friend, I have also tried Netbeans with the same steps, but not generated, and does not indicate an error me ... – user2974805 Jan 26 '14 at 07:30
  • did you add the driver? And did you test the connection to the database? It works just fine, I use that all the time in all my projects, so you are missing something... I see in the pucture that you are using eclipse I guess, here is how to do http://docs.jboss.org/tools/4.0.1.Final/en/hibernatetools/html_single/ this the official tutorial – Hassen Ch. Jan 26 '14 at 08:54
  • Hi, as said before, if I change the name of the table and its fields in lowercase, if generates POJOs, the question is why is not generated in capital letters ... – user2974805 Jan 27 '14 at 04:16
  • this is a commun problem, so it's not really a problem http://stackoverflow.com/questions/1867699/using-hibernate-tools-to-reverse-engineer-pojos-from-postgres?rq=1 – Hassen Ch. Jan 29 '14 at 00:25
  • You solve it somehow does not recognize the table name in uppercase, but if you recognize the attributes of the table in uppercase, so rename the tables in lowercase temporarily after he change in the EJB annotations, at least it works somehow. – user2974805 Jan 30 '14 at 02:52
0

You solve it somehow does not recognize the table name in uppercase, but if you recognize the attributes of the table in uppercase, so rename the tables in lowercase temporarily after he change in the EJB annotations, at least it works somehow.

user2974805
  • 43
  • 1
  • 7