GeneratingClasses and mappingFiles from database schema/ sql with ant/maven

hi,
I have an application using the the following ant script (it creates mapping files - hbms and sql schema for my database, basing on xdoclet for hibernate), (application also use spring beans in configuration file):
<?xml version="1.0" encoding="UTF-8"?>
<project name="demo" default="generate">
     <property file="build.properties" />
      <target name="init">
           <echo message="Clening..."/>
           <delete dir="target" failonerror="false"/>
           <echo message="Creating folders..."/>
        <mkdir dir="target"/>
        <mkdir dir="target/classes"/>
        <mkdir dir="target/jar"/>
           <echo message="Defining xdoclet2 ant task..."/>
        <path id="xdoclet2.task.classpath">
            <fileset dir="lib/xdoclet">
                <include name="*.jar"/>
            </fileset>
        </path>
        <path id="project.classpath">
            <fileset dir="lib">
                <include name="*.jar"/>
            </fileset>
        </path>
        <taskdef
            name="xdoclet2"
            classname="org.xdoclet.ant.XDocletTask"
            classpathref="xdoclet2.task.classpath"
            />
    </target>
     <target name="generate" depends="init" description="Cleans and builds everything.">
           <echo message="Generating hbms..."/>
        <xdoclet2>
            <fileset dir="source/src">
                <include name="**/*Model.java"/>
            </fileset>
            <component
                classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
                destdir="target/hbm"
                version="2.0"
                />
        </xdoclet2>
           <echo message="Compiling..."/>
          <javac classpathref="project.classpath" destdir="target/classes"
               srcdir="source/src">
          </javac>
           <echo message="Creating jar..."/>
          <jar destfile="target/jar/demo.jar">
               <fileset dir="target/classes"/>
               <fileset dir="resources"/>
               <fileset dir="target/hbm"/>
          </jar>
        <path id="hibernate.task.classpath">
            <fileset dir="lib">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="target/jar">
                <include name="*.jar"/>
            </fileset>
        </path>
           <echo message="Creating database schema..."/>
         <taskdef name="schemaexport"
              classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
              classpathref="hibernate.task.classpath"/>
              <schemaexport
                  properties="resources/hibernate.properties"
                  quiet="no"
                  text="no"
                  drop="no"
                  delimiter=";"
                  output="target/schema-export.sql">
                  <fileset dir="target/hbm">
                      <include name="**/*.hbm.xml"/>
                  </fileset>
              </schemaexport>
     </target>
</project>EXAMPLE MAPPING FILE:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
  <class table="DEMO_ADDRESS" name="amg.demo.model.AddressModel">
    <id unsaved-value="null" name="id">
      <generator class="native">
        <param name="sequence">id_seq</param>
      </generator>
    </id>
    <version unsaved-value="undefined" name="version" column="version" type="java.lang.Long"/>
    <property name="firstName"/>
    <property name="lastName"/>
    <property name="type" type="amg.demo.model.AddressTypeEnum"/>
    <property name="zipCode"/>
  </class>
</hibernate-mapping>I wish I would know how to make an inverse operation - I mean having the sql database schema I should generate classes and propably the mapping xml-es.
Could u please give me some example applications/ant or maven scripts with some database sql schemat or some not very complicated links to the tutorials concerning this problem?

If you're using Eclipse check out some of the Hibernate tools. I have used these before:
http://www.eclipse-plugins.info/eclipse/search.jsp?query=hibernate

Similar Messages

  • Need Database Schema diagram with reports names

    Dear Experts,
    I need retail and petroleum industry database schema diagram with different report requirements.
    If u have  Plz do share. I want to develop some reports as per requirements.
    If u have any sample dummy schema Plz do share, I will be much thankful to u. This is for fresher interview, I need to attain this week end.
    Regards,
    Mahesh.

    i dont think its possible with original exp/imp....and also not possible with data pump (10g and up)....but not sure on data pump....data pump has capability of restarting a job..but didnt heard about appending (atleast not that i heard).
    only way i can think of...create triggers on every table when DML happens and insert the new data into new tables...and then exp those new tables and import the new tables...thats the only way i can think of...again just my 2 cent....

  • Please provide me unix shell script (export and import of database schema)

    please i am new in unix
    \please give me sample unix shell script (export and import of database schema)

    please i am new in unix
    \please give me sample unix shell script (export and import of database schema)Instead of providing you the readymade unix shell script for your requirement, I will give you the hints to prepare the same at your own.
    Create a file with .sh extension.
    # Specify and set all required Environment variables.
    ORACLE_HOME, PATH, NLS_LANG, etc.,
    # Use the export command with all clauses
    export scott/tiger@orcl file=scott.dmp log=scott_emp.log
    # Compress it.
    compress scott.dmp
    Refer any unix/linux documents for scripting basics.
    http://www.bijoos.com/ora7/oracle_unix.htm
    Regards,
    Sabdar Syed.

  • Loading the username and password from database when login to xMII

    Hi
      can you explain briefly about how to configure the netweaver for loading username and password from database when the user login to xMII via netweaver platform?
    In xMII 11.5 we are configuring xMII itself? but in xMII 12.0 configuring by netweaver platform. if anyone know please explain step by step

    I am sending you some java code, which you can use in JSP.
    import java.sql.*;
    public class connectOracle{
    public static void main(String[] args) {
    System.out.println("Getting Column Names Example!");
    Connection con = null;
    String url = "jdbc:oracle:thin:@172.16.0.21:1521:orcl";
    String driver = "oracle.jdbc.driver.OracleDriver";
    String user = "scott";
    String pass = "tiger";
    try{
    Class.forName(driver);
    con = DriverManager.getConnection(url, user, pass);
    catch (SQLException s){
    System.out.println("SQL statement is not executed!");
    catch (Exception e){
    e.printStackTrace();
    }

  • How to extract all keys (PK, FK) and constraints from the schema?

    hi,
    How to extract all keys (PK, FK) and constraints from the schema?Thanks!

    I have no idea about any tool which only extract the DDL of constraints.
    In oracle 9i or above you can use DBMS_METADATA to extract DDL of a table which also shows contraints defination.
    You can take the tables export without data and use databee tool to extract the DDL.
    www.databee.com

  • Why can I not buy music and movies from the SA site with my SA credit card???

    Why can I not buy music and movies from the SA site with my SA credit card???

    I'll answer myself after reading the threads, now I am so sorry I bought the dam thing!!

  • Move Business Area and EUL from one schema to another

    Hi,
    I need to take a EUL from the schema where it is now and bring it to another schema. I use Oracle Discoverer 3.1 Admin Edition to Export Business Area then import it in the new schema. Everything works fine except the fact that workbooks (.dis file) created in the original schema returns no data (as it does in the original schema).
    Anybody can help ?

    Hi,
    There could be a number of reasons for this, but the first thing to check is whether Discoverer is generating the same SQL when the report is run in the two EULs.
    If the SQL is the same Discoverer could still return different data if for example there were user specific conditions in the query or language specific conditions in the query and the default language was different in the EULs.
    Are you using an Apps or database mode EUL? What is in the workbook query that you are running?
    Rod West

  • Invoke oracle report 10g from database pl/sql package

    Hi
    Is there a way that i can invoke an oracle report 10g from the database pl/sql package? I am working on a requirement that needs to generate a report when one of the criteria is not met.
    Please suggest me on this.

    Thanks for the info.
    I have a scenario where i need to fetch members details like name , email address and so on from the mainframes on the oracle database. Then on the oracle database i need to check if they have a email address or not. If yes then i need to generate a notice and mail it to them. If they don't have an email address, i'll have to print that out in a some centralized location.
    By the way, the notice was developed using oracle reports 10g.
    Now i am developing a pl/sql package which will do the address validation but i didn't know how to call a oracle report to generate the notice in pl/sql procedure.
    As suggested i will try with dbms scheduler and see if that works for me.

  • Moving procedures and sequences from one schema to another

    Hi all,
    Is there any way to export the procedures and sequences alone from one schema to another? If not is there any way to generate the procedure creating scripts from the source schema.
    I used the following script SET HEADING OFF
    SET PAGESIZE 999
    SET LINESIZE 100
    SELECT DBMS_METADATA.GET_DDL('PROCEDURE', NAME, owner) || '/' FROM ALL_SOURCE WHERE
    OWNER='SCOTT' AND TYPE='PROCEDURE'
    SPOOL C:\A.SQL
    SPOOL OFF
    [/CODE]
    But the problem is in the out put script it is cutting the line .. for egCREATE OR REPLACE PROCEDURE "QC_PFIZER_REL5"."SPGETNEXTDS
    S_ID"
    ( V_ID OUT NUMBER )
    IS
    BEGIN
    SELECT SEQUENCE_DSS_Id.NEXTVAL INTO V_ID FROM DUAL;
    END ;
    i experimented with increasing linesize but it is not helping. I am using 9.2.0.5 on windows 2003.
    Thanks
    Muneer

    Similar to getting the code from user_source, you could get sequences from user_sequences.
    SQL> select dbms_metadata.get_ddl('SEQUENCE', sequence_name) from user_sequences ;
    DBMS_METADATA.GET_DDL('SEQUENCE',SEQUENCE_NAME)
       CREATE SEQUENCE  "SCOTT"."SEQ"  MINVALUE 1 MAXVALUE 1.00000000000000E+27 INCR
    EMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
    1 row selected.
    SQL>

  • Passing params from SQL file to Shell Script and then from Shell to SQL Fil

    Afternoon guys,
    Have a fun question for all you gurus in shell scripting out there. I have a shell script that is calling 2
    different SQL programs. My objective is to pass a variable called request_number from one sql program
    to the shell script and then from the shell script back to another SQL program. I will explain why I
    need this to happen.
    Here is what the shell script looks like which calls sql programs student_load_a.sql and
    student_load_b.sql. Student_load_a.sql basically creates the control file (.ctl) which is needed for the
    SQL*Loader and then student_load_b.sql reads the table that was just loaded and does the main
    processing. My main objective here is to be passing the request_number which is being generated
    using an Oracle Sequence in student_load_a.sql and using this generated number in my main
    processing in student_load_b.sql to select records from the table based on request_number.
    Any ideas ?Any help or recommendations is welcome and appreciated.
    *1. Shell Script*
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id
    exit_status=$?
    # Do sqlloads
    sdesqlldr.exe userid=$p_user_id control=student_load-$p_job_id.ctl \
                                                 log=student_load-$p_job_id.log \
                                                 bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id
    exit_status=$?
    exit 0*2. student_load_a.sql (Would like to pass back the Sequence Number back to shell script and then use in student_load_b.sql*
    -- Accept system input parameters
    define p_job_id = &1
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ' || '''' || request_number_seq.nextval || ''',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    *3. student_load_b.sql (This is a big file so I am only adding code that is relevant for the SQL)*
    {code}
    declare
      v_request_number    number(6);
      v_student_id                  number(7);
      cursor cur_student_load is
        select  student_id
        from   TMP_STUDENT_LOAD
        where  request_number = v_request_number
        order by 1;
    begin
        v_user_id := '&1';
        v_job_id := &2;
        -- This is the variable I would like to be be passing from shell script to student_load_b.sql
        -- v_request_number = '&3';
         open  cur_student_load;
         fetch cur_student_load into v_student_id;
          exit when cur_student_load%notfound;
          .... more logic of if then else in here
         close cur_student_load;
    end;
    {code}
    Edited by: RDonASnowyDay on Jan 29, 2010 4:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    How come you are mixing WinDoze script (*.exe) with Unix?
    You are aware that you will be passing the password along with the user id to the second sql script?
    I will assume Unix ksh:
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    p_seqno=`sqlplus -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id`
    exit_status=$?
    # Do sqlloads
    sqlldr userid=$p_user_id control=student_load-$p_job_id.ctl \
           log=student_load-$p_job_id.log \
           bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql \
               $p_user_id $p_job_id $p_seqno
    exit_status=$?
    exit 0And the first sql script would look like this:
    -- student_load_a.sql
    -- Accept system input parameters
    set echo off pages 0 feed off lin 80 trims on ver off
    def p_job_id = &1
    col seqno NEW_VALUE seqno
    select request_number_seq.nextval seqno from dual;
    set term off
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ''&&seqno'',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    :p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Copy all tables and data from remote schema to local schema

    Hi,
    I am using Oracle 10g Enterprise edition as a database and Windows 7 as the operating system.
    My Requirement is to copy all the tables and data from remote machine database to my local machine.
    I created a DB link between my location schema and remote machine schema. Database link created successful. Error what i am getting when i am trying to import all the tables from the remote data is as mentioned below
    I created a directory gave all the privilege to do read and write on the directory.
    Directory name : DUMP
    Local Schema name / PASSWORD : PRODUCTION / PRODUCTION
    Remote Schema name / Password : portal / m3892!2
    When i run this scrip from command prompt
    impdp PRODUCTION/PRODUCTION DIRECTORY=DUMP LOGFILE=LOCALPROD_MERUPROD.log network_link=MERU_DEV_LOCAL_PROD schemas=portal remap_schema=portal:PRODUCTION TABLE_EXISTS_ACTION=REPLACE
    It is giving me following error please suggest me what is the mistake i couldn't trace
    ORA-31631: privileges are required
    ORA-39149: cannot link privileged user to non-privileged user
    Thanks
    Sudhir

    Thanks I gave the grant permission for the "portal" remote user. I didn't not get the error. Issue am facing now is I need to copy the entire schema of production to my local system production.
    I am currently using the below script to copy. it not working. what might be the reason there is no error message coming but still i don't see any tables in my local system after executing this script
    impdp PRODUCTION/PRODUCTION DIRECTORY=DUMP LOGFILE=LOCALPROD_MERUPROD.log network_link=MERU_DEV_LOCAL_PROD schemas=portal remap_schema=portal:PRODUCTION TABLE_EXISTS_ACTION=REPLACE
    Or suggest me some other script to copy all the tables and procedure function from remote database to my local database using impdp script
    Thanks
    Sudhir

  • Separate ASCS and PAS from Database server

    Dear friends, in a customer we have the following need:
    We need to separate de ASCS and the Primary application server to a host different from database server. The SAP system is an ERP 6.0 EHP4 based in NW 7.01.
    We have used Software provisoning manager to splitt off the ASCS from the CI. Before the splitt off we only had the directory DVEBMSG00, and after the splitt off, we had ASCS01 and DVEBMSG00 directories. But, this is only half of the solution, because we need to move this services to another hosts.
    We tried to use Software provisioning manager to deinstall the ASCS, and install it in the other host. This works. But the problem is the Primary application server, because if we uninstall it, when insttall in the other host with the option "System Copy" the sapinst promts for the installation export.
    In the Marketplace i could not find any note form aour scenario.
    Do you know a way to separate de CI and the PAS from de database server without a system copy?
    Thanks and best regards.

    Hi
    http://scn.sap.com/community/netweaver-administrator/blog/2013/12/04/why-splitting-off-the-ascs-from-pas
    This link might be useful
    But if you have a system based on SAP NetWeaver 7.0x, this option is not available in the 70SWPM, The only way to do that would be running a system copy of the system. Then during the target system installation, you would be able to install the new system with sepated ASCS from PAS . "

  • I have a macbook 2.1 with osx10.6.8 and want to wipe it clean and migrate from my macbook pro with the same osx..is it possible to do?

    I have an older macbook 2.1 intel OSX 10.6.8 that I want to wipe clean and then migrate from my  macbbok pro with OSX10.6.8 to the older macbook, is it possible ,how would I do it..especially how do I wipe clean the older macbook?

    Connecting to a TV is no different than connecting to any other external display. It's possible that there's a problem with the mini dvi port on the macbook r that you have bad adapters. You might try resetting the SMC Intel-based Macs: Resetting the System Management Controller (SMC) - Apple Support
    Does the Macbook recognize that there's an external display connected when you look at the Display preference pane?

  • Why can't I copy and paste from google seach history with firefox 4

    When I try and copy and paste from Google drop down search box nothing happens. Only happen with Firefox 4. I tried to roll back to 3.6 but every time i reboot it puts 4 back

    Same issue. Running 10.10. MBP Retina 13 (Early 2013).
    Previous attempts to resolve the issue
    a. have reset keyboard preferences
    b. have shut down and restarted twice
    c. have shut down and restarted in safe mode, then restarted to clear cache
    Learning: Appears to be just for browser software.
    To reproduce:
    1. Go into Safari or Firefox, select the URL or any text in the window, press CMD+C.
    2. Go to Word/Text Edit/Evernote or open a new tab in the browser and press CMD+V
    3. Nothing happens

  • Image upload and display from database blob coloumn in ADF

    HI
    how can i upload and display image from database ( blob ) coloumn in ADF

    Hi,
    Take a look to this video: http://www.youtube.com/watch?v=_KYquJwYFGE
    AP

Maybe you are looking for

  • !! Getting error while using function in where clause

    Hi, I have created a function as below create function find_cnt(n varchar2) return number is cnt number; begin execute immediate 'select count(1) from '||n into cnt; return nvl(cnt,0); end; and when running the below select select find_cnt(object_nam

  • Why is the size of WIN7SE updates 4 GB

    I never tried to add any update to my answer file until today. Once I applied applicable updates to the answer file, the ICE applied ~300 updates and the footprint size immediately expand from 2 GB to 6 GB. I tried to delete some unessential packages

  • Help with transferring contacts and messages

    Hi there - I would be grateful if someone could help me . I need to transfer my contacts and messages from my iPhone 4 to iPhone 5- Is there an easy way of doing this Manu thanks

  • How to create PO and Goods recipt simultanuosly

    Hi, we need  create PO with quantity same as the quantity received and Received quantity is directly posted to inventory as and when saved PO/created How to achieve this in SAP Advance Thanks Chidambaram

  • Question: How to remove prompt in recording using MMAPI

    Hi, we have been developing a softphone using j2me. Our goal is to record voice (using j2me) into a byte array and deliver that as a packet either through bluetooth or wifi. We need to capture voice at a certain interval, stop the capture, deliver, a