STS JPA Tools not generating all Entities from Tables - mysql

I have created a few tables in my DB and a demo project in STS which I have converted to a JPA project. I then right click on it and select JPA Tools -> Generate Entities from Tables.
It works perfectly, except that it does not generate all Entities from the Tables. I have added two new tables and can see the in the Data Source Explorer, but when doing the generation, entities for those two does not get generated.
I have had this problem before, it's almost as if STS is keeping cache or something from a previous generation and now doing only that, but I am not sure where to look or how to clean it.
Any help please.

Got it working,
For those of you interested, I had to select each table one by one and generate the Entity. STS does not like it when you select all tables. Just select one and generate the entity, then repeat the process for the next one, etc, etc.

Related

Creating a newsfeed in cshtml

I have the following in database
status table - status_id, status_body, status_date
student table - student_id, student_username, student_firstname, student_lastname
follow table - followId, follow_followerid, follow_followingid`
Now, I want to show the status of the users which a user(say user A) currently follows along with his(user A) own status updates.
How can I do it in cshtml? SQL query for this is necessary.
Any help?
You can't put a sql query in a cshtml file. There is a chain of events that have to happen. You serve the cshtml with only the results of your database query in it. You also need some server-side code to serve the cshtml, for example c# using MVC. And you need a way to access your database, for example an object-relational mapper such as Entity Framework. You have a lot of steps, if you want to make this work.

Adding tables via DAO to a database

As a general question which would really help me "connect the dots" with my studies.
I am currently doing exercises working with DAO and Learning how to add tables automatically. Although i have been working with databases for many years, i question, what type of scenerarios would it be vantagious to use this function. When is it necessary to add tables to a database in an automatic way? Up until now, in all my experiences the tables i need have Always been defined from the beginning and I cant think of a situation where I could of benefited from using this function. For example, i use frequently delete queries to help me clear tables and re-populate them, but when would it be necessary to actually "create" a new table"?
Yes, I have seen a scenario where new tables were created 'on the fly' (either via SQL create, or just DAO). With a shared database on a server, the application called for importing Excel data that a particular user was responsible for, so a table was created on the fly. Multiple users, changes in staff, need to keep data independent, etc. we could create their own table (name based on userid) that they had interfaces to do whatever they wanted with their own data. Not a typical scenario, but worked well for this application.

How to approach dilemma: export orders from old magento system import into new magento, overlapping IDs

During an upgrade from Magento 1.5 to 1.7 unfortunately we had to reinstall Magento (don't ask) and now I need to get all of the old order information into the live upgrade. I've researched several scenarios. First would be identifying the tables in the database they correspond to and migrating those tables over, but I have three issues with that. One: I already did a little bit of that and because of the discrepancies between 1.5 and 1.7 caused several hours of debugging fun. Two: I can't figure out specifically which of these freaking tables needs updating (was going to just replace all sales_ tables). Third: since the upgrade other orders have been placed, and as you know, started order ids all over again and I don't want those entries to get replaced.
My other choice is to attempt to build an extension like this one: http://www.magentocommerce.com/magento-connect/dataflow-batch-import-export-orders-to-csv-xml.html. I already started but alas am already stuck on the oAuth process.
Before I waste anymore time, I'd like some advice. What would be the best way to go about this process?
Update 1-17
I have tried UNION queries on applicable tables but of course I get error "#1062 - Duplicate entry '1' for key 'PRIMARY'" being there are several primary keys. Is there a query to increment those primary keys of the new orders to follow after the ids of the old orders? I tried to do this in individual columns via UPDATE sales_flat_invoice_grid
SET increment_id = (increment_id+6150) or similar, but the ids are mapped to the ids on other tables! Please help! I'm afraid I'm going to have to tell boss that we need to buy that extension.
Continued from comment above ^^
hmmm .. If that's the case, the way I've done exports/imports in the past (see my post HERE) is use MySQL Workbench EER Modeling tool to create myself a diagram of the order storage system. I would select only one table at first, then MySQL will tell you what other tables are tied to that table. I repeat this process so that in my EER diagram, I don't have unnecessary tables, and I am not missing tables. I end up with exactly the number of tables I need to understand the flow.
Next, do the same for your 1.7 setup ... And compare. You will need to generate a SQL query that will not only INSERT the 1.5 orders into the 1.7 database, but you may need to create your own link table in case there is an ID that is used, you may need to link X to Y by way of Z. It's messy, and a little confusing, but I spent 3 weeks writing a SQL/PHP script that pulled 1) Product Data, 2) Category Data, 3) Customer Data and 4) Order Data. I also wrote one for Admin backend users and preferences. This was before I discovered the aforementioned tool.
EDIT I might add , that extension is only $200.00. How much in development time is it going to cost your employer for you to develop your way out of this? Depending on your hourly cost (I know with what I charge, $200 would be a steal) it may make more sense to get the extension.

Correct foreigen key approach in jpa Or data saving basic approach

This question of mine is subjective
i am getting a list of objects from a third site.
now i want to save that data in database.
suppose the data is List. This response is to a query that i fired to that site .
now i want to save two things
1) query name
2) the response(List) (answer)
the myobject can have lot of answers corresponding to my query. now i want to save all these answers separately so that each answer can be fetched independently.
now i have this DB approach
one table for query and query id
second table which will consist of query id and query answer. (which will be foreigen key in first table
My question is am i following right approach?
initially i thought of saving the whole list in database but as per my knowledge we can not save list in database directly although in jpa implementation 2.0 we can save list in db (correct me if i am wrong)
please guide me with my current approach or of there is any better approach
i am using JPA 2.0 eclipselink.
Regards
Anil Sharma
What is your object model?
You can use OneToMany or ManyToMany to store a collection of Entity objects.
If you have a List or List you can store this using an ElementCollection.
But you may be better off creating an Answer or AnswerReference Entity.
See,
http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection

Create ERD for a mySQL DB by selecting only some of the main tables

I need to create an ERD for our DB system. As it happens, there are lots and lots of tables, and no one really understands much of it. What's more, the same DB has tables for different applications, so not all tables are relevant to my application. I need an ERD for only my application's tables.
I tried creating ERD from MySQL workbench. It allows me to select a subset of the tables to put on an ERD, but that's the problem: I don't know which tables to select ( One of the reasons to build the diagram in the first place :-) ).
What I do know are some of the 'main' tables involved. What I'm looking for is this: I tell the tool some 5-10 of these main tables I'm interested in, and the tool automatically picks up all the tables that are linked to these tables, and creates the ERD for them.
Any pointers?
Otherwise, I'll have to live with building my list of tables manaully, one by one...
http://www.fabforce.net/ has a nice tool called DBDesigner, I have used this in the past for some reverse engineering on a datamodel.