Generate php entities from orm.xml Doctrine - orm

Hi I'm on Symfony 5 and I'll like to generate php entities and update the scheme from a orm.xml file.
I think it worked before with doctrine:generate:entities command.
Any solution? Thanks in advance

The command doctrine:generate:entities was removed. The Doctrine ORM team does not encourage creating entities from existing schema and therefore deprecated that functionality in the ORM.
With the MakerBundle you can create entities, but as far as I know it won't create them from a schema, so you have to manually create each Entity, which admittedly can be annoying if you just want to generate them based on the existing schema anyway. Alternatively you can create a new "legacy" Symfony application (e.g. based on version 3.4 as this should still have the command), create the entities from the schema as described in the docs, and then copy the generated entities over into your project. You will likely also have to run a search & replace for AppBundle\Entity -> App\Entity.

Related

jhipster entity - what exactly is that?

I am wondering what jhipster entities are exactly?
What if I just want to create a new page/view without any database entry and relationship? For example: the about page, do I have to use the entity generator in order to create it? What are the benefits of it?
jhipster entity tutorial
Regards
redyar
Entities are typically objects that are backed by a database table. With JHipster, you can generate entities (and their associated screens) using Yeoman.
For an about page, or any other page, you can author them by hand. You don't need to use a generator. JHipster merely provides its entity sub-generator as a convenience for you.
You can also use the Yeoman generator for AngularJS to generate basic scaffolding.
http://yeoman.io
Immagine to build a website of e-commerce. That website contains users, sensible data informations, details about sellers and other things. You can save a lot of time creating it with Jhipster because it automatically create Objects class that represents database's tables, RESTful web services to manage them and the frontend view with Angular, CSS and HTML (all generated automatically). The objects that represent database's tables are entities.
With entities you can do CRUD queries on database using Java objects and Java methods with Spring framework. You can do queries by calling java methods. Thats all! After some practice it's really easy to use.
With that generator you don't have to configure relationships, constraints or things like that. Jhipster does that for you!
If you need a web application that does not use a database you don't need to use a generator like this, in my opinion.
I took the right Matt Raible's answer trying to give you more informations about entities. I hope to be helpful!
Have a nice day!

Adding Plain SQL Tables to Grails App instead of using ORM?

In Grails, how can plain SQL/DDL be used to create / drop tables in the same manner they would be if one were using GORM / ORM?
For example, when using GORM / ORM, the tables used for persistence are regularly created/dropped, and inserted into, during the runtime of Integration Tests, and execution of the application.
I know there is a way to do this using just Groovy as shown in the example named "Advanced Usage" here, but I'm looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.
I'm looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.
As far as I know, there is no such support built-into Grails, so you'll have to write it yourself. Luckily it shouldn't be too difficult. Here's an implementation plan:
Store your DDL file in the conf directory
In Bootstrap.groovy, dependency-inject the DataSource Spring bean
In the init closure of Bootstrap.groovy use the DataSource to get a Connection to the DB
Using the Connection, create the database and execute the SQL statements in the DDL file against it
In the destroy closure of Bootstrap.groovy, drop the database

Multiple database with NHibernate 3.x

I found a couple of articles how to use NHibernate with multiple database, for example this one
http://codebetter.com/karlseguin/2009/03/30/using-nhibernate-with-multiple-databases/
But all articles are very old, and may be there is some new approach with NH 3.x? I looked in documentation but did not found anything, but maybe i missed somthing?
Does anybody knows some better way (native NH3.x way) to use NH 3.x with multiple database than described in this article?
http://codebetter.com/karlseguin/2009/03/30/using-nhibernate-with-multiple-databases/
Thanks,
Alexander.
AFAIK, there is nothing new in NH 3. But there are still more options to use several databases than in the blog post you linked.
You can open your own connection and pass it to NH when opening a session.
You can open a session and switch to another database on the same server (eg. by executing a use database statement on sql server).
You can provide a schema (database) name on each table you map in the mapping file. It is not useful to have it hard coded, but you can still replace it after loading the mapping files or use mapping by code.
The articles you linked are still the way to go. Each SessionFactory is responsible for a single connection (connectionstring) and schema.
There is one special case where ou split the database into multiple with the same schema to load balance. This is called sharding and there is the contrib NHibernate.Shards to deal with it.

Rails3 Devise authentication Migration

I have been messing around with how it will be best for my new application to represent the users table in the database.
I noticed a migration named like this:
20110512234640_devise_create_users.rb
Is that something that Device creates upon its install? Or can I just use a simpler users table migration that I'd write by hand?
How do people usually configure Devise and still be able to add on extra columns to the users table which their particular applications might need?
Thanks,
Alex
Usually you can create on more migration to add your own fields to Devise used table (this is to keep devise migration clear and simple)
You're right, it is an automatically generated migration by Devise which allows you to choose your Devise modules more easily since default modules are added to the migration and others are there too but commented.
Of course, you can use a written-by-hand user migration.
Personally, I use that generated migration to add my own extra fields. But using a custom user migration file is the same.

Managing updates with NHibernate

I am aware that you can generate create scripts to generate database objects, but I am looking a way to generate an update script that compares two different schemas (two mapping files).
That way I can provide my users with easy database updating from any version to the current version.
Thanks!
What you are looking for is Migrations. Have a look at the Fluent-Migrator project.