I had a working project in eclipse which created a JPA table from entity to mysql database (still learning). Unfortunately it made the table in the wrong database as I wanted there to be 'test' and 'production' databases. Somehow it got the details for the 'production' db, even that it looked like the selected database connection was for the test.
I tampered with the project a bit and made it to connect with right connection object for certain (test). I can ping the db in eclipse (both dbs) and see the db in the Data Source Explorer.
But now I can not create the table(s) for the project by right clicking on it and selecting 'JPA 'Tools' > 'Generate Tables from Entities'.
The creation starts and finishes with no errors, like everything works, yet I see no tables in either of the databases. (In eclipse Database explorer or from command line).
The persistence.xml should be fine as it already created that one table before.
The only error is for the Entity class as it says for the Entity annotation "Table xxx cannot be resolved". And as I see, it's coming from the table not being created.
Here's the persistence.xml just in case.
http://pastebin.com/djPZei90
The project is also a Maven project and it uses SVN. The dependencies were successfully loaded by the maven for the eclipse/project and there is no complications with the SVN.
Because of Maven there are 2 persistence.xml files (only the login credentials and the database name changes), for production and test. It could be that the db-connection was checked and loaded from the wrong file at the 1st place. (just guessing)
Also I tried to create the script.sql when generating the table(s). I found the file but it was completely empty.
Anyway the problem is now that I can't create the tables anywhere.
I am totally puzzled by this. Any hints where I should look to fix this?
Chris had it right, even that I didn't understand the answer correctly at the first reading.
I tried with the other provider, but I may had modified the wrong file by accident (2 'persistence.xml' files as it's a maven project), or there may have been some other reason I failed to spot.
I was given a hint earlier, that I should use the given provider (in persitence.xml). Causing that I didn't pay too much attention to it after all. Since using eclipselink, the provider has to be indeed:
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Thanks again Chris, even that I failed at the first attempt and had to spend several more hours on resolving this.
Could you solve the problem? Unfortunately I have stumbled on the same rare issue, which totally makes no sense. The JPA Tools just doesn't add the mapping classes for whatever reason, although it writes them into the persistence.xml.
Previous week everything worked flawlessly but now everything is f**. I even created a new independent project in different workspace but it happens the same bug. Obviously it's an eclipse/plugin bug, otherwise I can't explain it. Working with eclipse 4.2.0. I am not happy.
Edit: After removing Dali Tools, JPA Configurator, Seam 3 Plugin creating entities seems to work again. Don't know why, most likely a conflict, but it still doesn't explain why it happened now and not 1 month ago. I didn't change my eclipse install at all since then...
Spend the whole day on this.
I created a completely new (JPA) project in Eclipse (Indigo btw).
Also created a new database (mysql) for that.
Made a connection in Eclipse for that. File > New > Other... > Connection Profile.
Made a new package structure and let the Eclipse create the 'persistence.xml' (src/META-INF/persistence.xml).
I made an 'JPA Entity' class with eclipse wizard. (added 'id' (PK) and 'content' fields)
Copied the 'pom.xml' from my previous project to the new one (made only minor changes like the project name).
Also copied the 'persistence.xml' file from the previous project (src/main/java/META-INF/, no 'test' included). Changed database details and login credentials from the persistence file.
Made the project 'Maven project' in eclipse (right click on project name > Configure)
As it was now a Maven project the default 'persistence.xml' could be removed as it was in wrong place. (Mavenizing the project removed all the errors from un-existing jars with the pom.xml)
Tried to create the table again for the project (Same error, but wait...).
Right clicked on project > Maven > Disable Maven Nature
Then again made it maven project, right clicked on project > Configure > ...
Tried creating the tables again and it created them. Everything works!
Go figure!
Seems like everything was ok, like I suspected. There seems to be some sort of bug with maven (plugin) + eclipse.
Doing the same tricks on the previous project won't help. I even created the entity class with the wizard (removed the existing). The <class> declaration is added to the 'persistence.xml', but it still wont do the table. (Also tried removing and re-adding the maven nature)
I could be missing something on the process/did it differently or doing it wrong whole together. But considering I get the other project work while other doesn't, using the same tricks, there seems to be a big nasty bug.
Related
Ok so Im am still very new to javafx and intellij. I am working on a little project of my own right now and all I am trying to build is a simple calendar just like apple's version or google's. I figured this would be a good exercise for me to get to know the Intellij IDE better and JavaFX.
Here is the problem that I seem to be stuck with for a couple days now. In my application, a user has the ability to create a new event which contains many properties such as "event name", "first name", "last name" etc.. Now all the information is stored in a shall we call it "NewEvent" Node. Here lies the problem I am facing. I am trying to save the data locally on the clients computer however I am not sure how to begin. I have browsed around and I have found this thing called MYSQL that is supposed to do just that. I was hoping you guys could help me out here on how I should set this up.
Here is what I've done so far.
Downloaded MYSQL v5.7
Downloaded MYSQLWorkbench
Created a Database called "event" with all the properties contained in the Node
Somehow added the MYSQL database to intellij
Created a dialog where if the user clicks save, all the information is stored in a node.
To my understanding in order to access the data stored in the MYSQL table, shouldnt the "data file" be saved in my project folder? I have no clue where this is located. Also how would I gain access to database in order to edit it dynamically. Like adding a new row to the database.
I have looked up online with many different searches but they all seem to be using NetBeans and they are mostly outdated. I found it really hard to find information from start to finish. All I want to do is to store data locally and to access it. I expect to have a largely populated database, seeing as no one actually deletes an event once its over so what I was told is that MYSQL is capable of handling huge data. Hence my choice to go along with it.
I have done a little Android Application last summer so I am a little familiar with MYSQL, however I remember saving the data onto a table on the clients phone.
MySQL isn't an embedded database. Only the libmysqld is embeddable.
You can integrate JavaFx application with any database. HSQLDB or H2 would be more appropriate, since they do not need an installation on the client machine, and can be configured to save the data file on any location.
I am using PhpStorm 2016.1.2 and have been comfortably using PhpStorm for a couple of years. I have my Storm set up with the Database connection and displaying the MySQL database that my PHP pages connect to. The SQL is usually written within the PHP page in custom functions via a database connection class.
An example code chunk:
$checkData = $dataBaseSecure->getSelect(
"SELECT check_login.fail_id, UNIX_TIMESTAMP(check_login.last_action) AS timer
FROM check_login WHERE check_login.ip_addr = ? AND check_login.check_drop = ? ",
$data, TRUE);
Don't worry about the database PHP wrapper, this style and layout of SQL in PHP has been around on my work for a couple of years, in PhpStorm and works completely and accurately on the server and on all testings.
As Of Yesterday (17th June 2016)
I don't know what's changed but suddenly PhpStorm is now telling me, on all my SQL strings, across all my Projects:
Unable to resolve symbol '<table name>'
or
Unable to resolve column '<column name>'
And also (due to this) PhpStorm no longer carries out any auto-complete or organisation functions as I work on my SQL code.
Solutions I've tried
I have already tried to invalidate and revalidate my caches based on this answer to a similar question. But that hasn't helped.
I have very carefully explored my settings but the PhpStorm Database tab successfully connects to the database, and as far as I'm aware I made no changes to cause this change in behaviour.
I have looked over the various (and many) settings in PhpStorm preferences but seen nothing that has shone any light on this issue, or the changes I have tweaked have not resolved it.
I have found this answer but this does not seem to apply as my table names are not variables. I have also found this post, which while dated 2014 shows a similar issue but not a suitable solution.
I only have one database connection in most projects, but the number of databases doesn't seem to effect if this issue occurs.
Fully escaping SQL queries with appropriate backticks around named entities does not resolve the issue.
I have correctly configured my SQL dialect to the correct MySQL.
Reading related posts I'm found on Stack Overflow has provided no useful information.
I have no plugins in PhpStorm that relate to this issue or PHP/MySQL interaction.
If you have any ideas how to resolve this please tell me. If you have specific preferences you'd like me to check please let me know and I can add them into the question, (there are so many preferences in PhpStorm I won't post them all here right now, as I'm sure most are not related to this issue).
The Key is that this system was working perfectly two days ago!!!
Please try re-synchronizing your DB schemas -- just in case if it somehow got corrupted or invalid.
If it did not give any visual results -- try more radical version of it:
close IDE
open .idea subfolder for this project (the place where this project settings are stored)
delete dataSources.ids file
re-open project in IDE
re-sync DB structure / re-create DB connection from scratch.
None of the above worked for me - what eventually did was...
Selecting a portion of the SQL string that would run and then right clicking and selecting "Execute" and selecting the schema.
For some reason that allowed PHPStorm (more like light
drizzle) to figure out what it should be looking at.
how to see my liferay table in mysql database?
i have created portal-ext.properties in liferay home.but i cant see my liferey table mySql..
table is created in docroot/web-inf/sql in eclipse IDE...
help me where i m wrong and which thing missing?
#
# MySQL
#
include-and-override=portal-ext.properties
include-and-override=${liferay.home}/portal-ext.properties
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/kportal?useUnicode=true&characterEn
coding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=ubuntu123
schema.run.enabled=true
schema.run.minimal=true
Tables created through service-builder will only be created once you deploy your plugin to the actual server (and run the server), not on build time. Also, your plugin needs to deploy correctly - if initialization fails (e.g. due to missing pieces or dependencies that are not met), the tables will not be created.
Also, the tables by default will be named with the namespace you gave as a prefix. So if you declare a namespace X (in service.xml) and an entity named Y, the table to look for will be named X_Y.
Also, remember you'll have to run ant build-services after you edited your service.xml. Then deploy it and wait for a log message similar "...your plugin... is available for use" to be sure it deployed correctly. (Edit: This is no longer printed for portlets, only for the other plugin types, so you might not see it when you deployed your plugin)
If this doesn't help, please give more information. Currently you don't give any details about what you've actually tried. You'll find more steps and details on the development guide.
Also, make sure
that the account you use for the database has CREATE TABLE permissions (you use root in your configuration above - that should do the trick)
that you're checking the correct database in case you have multiple
that Liferay actually picks up your configuration file. The startup log will tell you which portal-ext.properties files are read, as well as which database it will use. In case you can't find the name/location of your portal-ext.properties file, make sure that you indeed have a file with this name. A common problem on windows is that people create portal-ext.properties.txt (and Windows hides the .txt part of the name)
I learned play by following the tutorial on their website for building a little blogging engine.
It uses JPA and in it's bootstrap calls Fixtures.Deletemodels(), (or something like that).
It basically nukes all the tables every time it runs and I lose all the data.
I've deployed a production system like (sans the nuke statement).
Now I need to deploy a large update to the production system. Lots of classes have changed, been added, and been removed. In my testing locally, without nuking the tables on every run I ran into sync issues. When I would try to write or read from tables play would throw errors. I opened up mysql and sure enough the tables had only been partially modified and modified incorrectly in some cases. Even if I have the DDL mode set to "create" in my config JPA can't seem to "figure out" how to reconcile the changes and modify my schema accordingly.
So I have to put back in the bootstrap statement that nukes all my tables.
So I started looking into database evolutions within Play and read an article on the play framework website about database evolutions. The article talked about version scripts, but it said, "If you work with JPA, Hibernate can handle database evolutions for you automatically. Evolutions are useful if you don’t use JPA".
So if JPA is supposed to be taking care of this for me, how do I deploy large updates to a large Play app? So far JPA has not been able to make the schema changes correctly and the app will throw errors. I'm not interested in losing all my data so the fix on dev "Fixtures.deleteModels()" can't really be used in prod.
Thanks in advance,
Josh
No, JPA should not take care of it for you. It's not a magic tool. If you decide to rename the table "client" to "customer", the column "street" to "line1" and to switch the values of the customer type column from 1, 2, 3 to "bronze", "silver", "gold", there is no way for JPA to read in your mind and figure all the changes to do automagically.
To migrate from one schema to another, you use the same tools as if you didn't use JPA: SQL scripts, or more adavanced schema and data migration tools, or even custom migration JDBC code.
Have a look at flyway. You may trigger database migrations from your code or maven.
There is a property called hbm2ddl.auto=update which will update your schema.
I would STRONGLY suggest to not use this setting in production as it introduces a whole new level of problems if something goes wrong.
It's perfectly fine for development though.
When a JPA container starts (say, EclipseLink or any other), it expects to find a database which matches #Entity classes you've defined in your code. If the database has been migrated already, everything will work smoothly; otherwise: probably it will fail.
So, long story short, you need to perform database migrations (or evolutions, if you prefer) before the JPA container starts. Apparently, Play performs migrations for you, before Play kicks off the database manager you configured. So, in theory, regardless the ORM you are using, Play decides when it's time for the ORM to start its work. So, conceptually it should work.
For a good presentation about this subject, please have a look at the second video at: http://flywaydb.org/documentation/videos.html
I get this error no matter what version of SubSonic I use. When I query the database for data, it errors out, saying it can not connect to the database.
However, it is able to generate the .cs classes(ActiveRecord, Context, etc) when told to do so.
Any help is appreciated.
Thanks folks...
My guess is that you have your SubSonic generated classes in a separate project from where your main application is (in another project in the same solution). Your main application project references the project containg the SubSonic generated classes.
If this is the case, your main application project must also contain the connection string in a config file, similarly to what your other project has. You might also need to copy over some of the other SubSonic related items from your other project's config file as well.