Is it possible to upgrade the DB schema with EJB?
Lets say I have an EJB application which defines some entities and relations among them. I figured the DB schema can easily be created from the entities. So now the app works but after a while a need to change some relations, e.g. a one-to-one needs to become a one-to-many, can I upgrade my DB to do so WITHOUT losing the old data?
Asked by: Briony409 | Posted: 21-01-2022
Of course you can! What you have to do exactly depends on many different factors: Which ORM do you use? Which EJB container? Which RDBMS?
Usually the following steps apply:
- Stop the application
- Backup your database
- Edit your database schema
- Undeploy the application
- Adapt the application to your new schema. Don't forget to edit you ORM-Configuration!
- Redeploy the application
- Restart the application
To get a more detailed (and helpful) answer, you'll have to give us a lot more details of the current situation, of what you want to achieve and what you're going to change.Answered by: Alberta362 | Posted: 22-02-2022
In case of using Hibernate as JPA implementation you can pass property hibernate.hbm2ddl.auto. If you change schema manually you should think about setting it to "validate". Also you can try "update" which should take care of simple stuff without manual changes.Answered by: Patrick976 | Posted: 22-02-2022
It sounds like you're letting the container autogenerate the schema from your entities so you don't have to do get down and dirty creating your own ORM (why not?) If so, there's a nifty tool at the Apache project called DdlUtils that you might find useful.
First backup the old database, then redeploy your updated app to generate an empty database with the new schema. Using DdlUtils, you can then connect to the two databases and have it generate the SQL necessary to migrate your old database to the new schema, preserving your data.
It works like a charm if you're just adding or deleting tables or columns. I don't know how well it works when you do something like change column names. You may need to hand edit the sql in that case.Answered by: Oliver644 | Posted: 22-02-2022
java - How do you decide when to upgrade a library in your project?
I work on a project that uses multiple open source Java libraries. When upgrades to those libraries come out, we tend to follow a conservative strategy: if it ain't broke, don't fix it if it doesn't have new features we want, ignore it We follow this strategy because we usually don't have time to put in the new library and thoroughly test the overall application. (Like many software d...
java - How do I upgrade the version of a maven plugin?
I am using the maven-ear-plugin version 2.3.1 - I know there is a new version available: http://maven.apache.org/plugins/maven-ear-plugin/ I can't work out how to upgrade to the latest version?
java - JBoss 3.2.2 and JDBC upgrade
Moved a bunch of databases from sql server 2000 to 2008. One of the applications is on JBoss 3.2.2 and is now failing to connect to the database. The particular error is "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorect. Parameter 1 (""): Data type 0x38 is unknown." I looked around google for a while have determined this is because I'm using MS SQL Server 2000 Driver for JDBC a...
java - Is it possible to prompt or force a user to upgrade their JVM with a JNLP?
I need to prompt users to upgrade from JVM 1.5 to 1.6 when they run my Web Start application. Is this possible using JNLP settings?
upgrade - How to Debug while Porting from Java 1.5 to 1.6?
I have a distributed JBoss-based application that shows a buggy behavior when compiled and run with Java 1.6. It shows an another bug when compiled with Java 1.5 and run with Java 1.6. But it works fine when compiled and run with Java 1.5. What is the best approach to debug this application? Is there a lint for Java 1.5 to 1.6 conversion? Of course the behavior also depends on the third-party libraries I am using....
java - jvm crash after system upgrade
We have a tomcat application that started crashing every 10-15 minutes after we upgraded the OS ("aptitude dist-upgrade" of the system, which is a 32-bit Debian Lenny). java didn't get upgraded. A Full thread dump is generated in catalina.out when jvm crashes. But there is no error/exception showing in any of the threads. Does anyone know what might have caused the problem? Thanks. Here is the beginning of threa...
upgrade - End of life of IBM JDK/JRE 5?
Is there an announced end of life/end of support-date for the ibm jdk 5 (on Solaris/SPARC and Linux/x64)?
java - BIRT 2.3.2 to 2.6.0 upgrade error
I am getting the following error when I try to upgrade the BIRT version that is embedded in my custom web application java.lang.NoSuchMethodError: org.eclipse.birt.report.engine.api.EmitterInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Lorg/eclipse/birt/core/framework/IConfi...
java - upgrade to javaserver faces. Easy task?
I have the following question: First of all, I know (and have some academic experience on) JSP and Struts but I know nothing at all about JSF. There is a project that has its front-end already made using applets. I was asked to look into to change/upgrade it to JSF. So my question is, is this an easy or at least straightforward task? I am asking this since i)I do not know the learning curve of JSF ...
java - Upgrade path for json file format
We are storing user preferences for a Java app in a JSON file using Jackson. As we continue to develop the app, we will be adding preferences, renaming preferences, and removing obsolete preferences. When the user upgrades the app to the next version the file format will likely have changed. This causes Jackson to throw an exception and the file can't be parsed e...
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)