academiadocodigo / simpleorm Goto Github PK
View Code? Open in Web Editor NEWORM Simples para Aplicações Delphi
License: MIT License
ORM Simples para Aplicações Delphi
License: MIT License
[08:33:45] [Server thread/WARN]: Nag author(s): '[[email protected]]' of 'PlayerSQL' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[08:33:45] [Server thread/INFO]: [PlayerSQL] ORM lib load okay!
[08:33:46] [Server thread/ERROR]: [com.avaje.ebean.config.PropertyMapLoader] ebean.properties not found
[08:33:46] [Server thread/INFO]: [com.avaje.ebeaninternal.api.ClassLoadContext] Ambiguous ClassLoader choice preferContext:true Context:org.bukkit.plugin.java.PluginClassLoader Caller:org.bukkit.plugin.java.PluginClassLoader
[08:33:46] [Server thread/INFO]: [com.zaxxer.hikari.HikariDataSource] PlayerSQL@48188640-4978-46c1-b96e-47d05f0672b7 - Starting...
[08:33:47] [Server thread/ERROR]: [com.zaxxer.hikari.pool.HikariPool] PlayerSQL@48188640-4978-46c1-b96e-47d05f0672b7 - Exception during pool initialization.
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:453) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[patched_1.17.1.jar:git-Paper-325]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.checkDataSource(DefaultServerFactory.java:472) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:170) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:63) ~[SimpleORM.jar:?]
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:78) ~[SimpleORM.jar:?]
at com.mengcraft.simpleorm.EbeanHandler.initialize(EbeanHandler.java:270) ~[SimpleORM.jar:?]
at com.mengcraft.playersql.PluginMain.onEnable(PluginMain.java:92) ~[playersql.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:502) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:544) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:458) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:725) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-325]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
[08:33:47] [Server thread/ERROR]: Error occurred while enabling PlayerSQL v2.12.2 (Is it up to date?)
com.mengcraft.simpleorm.DatabaseException: javax.persistence.PersistenceException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mengcraft.simpleorm.EbeanHandler.initialize(EbeanHandler.java:272) ~[SimpleORM.jar:?]
at com.mengcraft.playersql.PluginMain.onEnable(PluginMain.java:92) ~[playersql.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:502) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:544) ~[patched_1.17.1.jar:git-Paper-325]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:458) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:725) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-325]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-325]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
Caused by: javax.persistence.PersistenceException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.checkDataSource(DefaultServerFactory.java:482) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:170) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:63) ~[SimpleORM.jar:?]
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:78) ~[SimpleORM.jar:?]
at com.mengcraft.simpleorm.EbeanHandler.initialize(EbeanHandler.java:270) ~[SimpleORM.jar:?]
... 11 more
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:453) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[patched_1.17.1.jar:git-Paper-325]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[patched_1.17.1.jar:git-Paper-325]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115) ~[SimpleORM.jar:?]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.checkDataSource(DefaultServerFactory.java:472) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:170) ~[SimpleORM.jar:?]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:63) ~[SimpleORM.jar:?]
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:78) ~[SimpleORM.jar:?]
at com.mengcraft.simpleorm.EbeanHandler.initialize(EbeanHandler.java:270) ~[SimpleORM.jar:?]
... 11 more
Quando compila para Android, o método SimpleRTTI.Fields está listando os atributos das classes java que o Delphi gera.
O retorno da função no prjSample fica assim: 'ID, NOME, DATA, VALOR, RefCount, Disposed '
Precisa ignorar os atributos RefCount e Disposed para não dar problema com o sql.
Esse commit: 9656ce5
Adicionou o Unidac como dependencia, fazendo com o que o projeto não compile sem ele.
Acho que componentes não nativos tinham que ser carregadas de forma opcional.
Olá! Sou novo no Delphi e estou com um probleminha...
Os retornos das várias funções Find não retornam uma lista que possa ser atribuída a um TObjectList ou um TList,
estou tendo problemas para manipular os dados porque não consigo atribuí-los a uma variável com tipo adequado.
Alguém pode me ajudar?
Trecho do código:
var
Pedidos: TObjectList<TPEDIDO>;
Pedido: TPEDIDO;
begin
Pedidos := TObjectList<TPEDIDO>.Create;
Pedidos := DAOPedido.Find(Pedidos);
try
for Pedido in Pedidos do
begin
Memo1.Lines.Add(Pedido.NOME + DateToStr(Pedido.DATA));
end;
finally
Pedidos.Free;
end;
saída:
[dcc32 Error] U_SimpleORM.pas(53): E2010 Incompatible types: 'System.Generics.Collections.TObjectList<Entidade.Pedido.TPEDIDO>' and 'SimpleInterface.iSimpleDAO<Entidade.Pedido.TPEDIDO>'
Ajuste de diretiva de compilação para FMX na classe SimpleRTTI segue em anexo.
implementation
uses
SimpleAttributes,
{$IFNDEF CONSOLE}
{$IFDEF FMX}
FMX.Graphics,
{$ELSE}
Vcl.ComCtrls,
Vcl.Graphics,
{$ENDIF}
{$ENDIF}
Variants,
SimpleRTTIHelper,
System.UITypes;
O formato utilizado do banco de dados apenas funciona em máquina que tenham as configurações definidas para pt-BR. É necessário que o código leia as definições locais do utilizador e as use para tratar os dados.
Entidade.DoublePK missing
function TSimpleSQL.LastID(var aSQL: String): iSimpleSQL;
function TSimpleSQL.LastRecord(var aSQL: String): iSimpleSQL;
select FIRST 1 não existe no MySQL, q deveria ser no final colocar LIMIT 1.
Eu sou programador q ainda estou aprendendo as boas praticas MVC etc.. então não muito indicador pra dar um boa solução para este caso. Só estou mostrando algo q possa ser melhorado por alguém.
Pra mim, eu fiz um overload dessas 2 functions para pode usá-la no meu sistema.
Fiz alterações na UNIT SimpleRTTI para o atributo Ignore, quando criava um propriedade memos com a tag ignore ocorria um erro typecast segue modificações
function TSimpleRTTI.FieldsInsert(var aFields: String): iSimpleRTTI;
var
ctxRtti : TRttiContext;
typRtti : TRttiType;
prpRtti : TRttiProperty;
Info : PTypeInfo;
vIgnore : Boolean;
Attribute: TCustomAttribute;
begin
Result := Self;
Info := System.TypeInfo(T);
ctxRtti := TRttiContext.Create;
try
typRtti := ctxRtti.GetType(Info);
for prpRtti in typRtti.GetProperties do
begin
vIgnore := false;
for Attribute in prpRtti.GetAttributes do
begin
if Attribute is AutoInc then
vIgnore := True;
if Attribute is Ignore then // Adelson Inserido
vIgnore := True;
end;
if not vIgnore then
aFields := aFields + prpRtti.Name + ', ';
end;
finally
aFields := Copy(aFields, 0, Length(aFields) - 2) + ' ';
ctxRtti.Free;
end;
end;
function TSimpleRTTI.DictionaryFields(var aDictionary : TDictionary<string, variant>) : iSimpleRTTI;
var
ctxRtti : TRttiContext;
typRtti : TRttiType;
prpRtti : TRttiProperty;
Info : PTypeInfo;
Aux : String;
vIgnore : Boolean; // Incluido Adelson
Attribute: TCustomAttribute; // Incluido Adelsok
begin
{
Original
Result := Self;
Info := System.TypeInfo(T);
ctxRtti := TRttiContext.Create;
try
typRtti := ctxRtti.GetType(Info);
for prpRtti in typRtti.GetProperties do
begin
case prpRtti.PropertyType.TypeKind of
tkInt64,
tkInteger : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsInteger);
tkFloat :
begin
if CompareText('TDateTime',prpRtti.PropertyType.Name)=0 then
aDictionary.Add(prpRtti.Name, StrToDateTime(prpRtti.GetValue(Pointer(FInstance)).ToString))
else
aDictionary.Add(prpRtti.Name, __FloatFormat(prpRtti.GetValue(Pointer(FInstance)).ToString));
end;
tkWChar,
tkLString,
tkWString,
tkUString,
tkString : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsString);
tkVariant : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsVariant);
else
aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsString);
end;
end;
finally
ctxRtti.Free;
end;
}
Result := Self;
Info := System.TypeInfo(T);
ctxRtti := TRttiContext.Create;
try
typRtti := ctxRtti.GetType(Info);
for prpRtti in typRtti.GetProperties do
begin
vIgnore := false;
for Attribute in prpRtti.GetAttributes do
begin
if Attribute is Ignore then
vIgnore := True;
end;
if not vIgnore then begin
case prpRtti.PropertyType.TypeKind of
tkInt64,
tkInteger : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsInteger);
tkFloat :
begin
if CompareText('TDateTime',prpRtti.PropertyType.Name)=0 then
aDictionary.Add(prpRtti.Name, StrToDateTime(prpRtti.GetValue(Pointer(FInstance)).ToString))
else
aDictionary.Add(prpRtti.Name, __FloatFormat(prpRtti.GetValue(Pointer(FInstance)).ToString));
end;
tkWChar,
tkLString,
tkWString,
tkUString,
tkString : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsString);
tkVariant : aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsVariant);
else
aDictionary.Add(prpRtti.Name, prpRtti.GetValue(Pointer(FInstance)).AsString);
end;
end;
end;
finally
ctxRtti.Free;
end;
end;
O SQLServer não permite update em campo PK. Talvez um atributo ReadOnly pudesse resolver este problema.
A biblioteca funcionar para views em FMX?
erro ocorre na unit SimplesDAO function TSimpleDAO.FillParameter(aInstance: T): iSimpleDAO;
onde os param são passados como variante FQuery.Params.ParamByName(Key).Value := DictionaryFields.Items[Key];
Com alteração abaixo não teria mais problemas em carregar grandes testos ate mesmo campos blob do banco.
if Length(DictionaryFields.Items[Key]) > 4000 then
FQuery.Params.ParamByName(Key).AsMemo := DictionaryFields.Items[Key]
else
FQuery.Params.ParamByName(Key).Value := DictionaryFields.Items[Key];
Boa noite, pessoal.
Postei esse problema no grupo do Telegram, mas estou postando aqui também.
Estou trabalhando em um projeto VCL, aplicados as técnicas do curso DDI e DDE. Com isso passei a utilizar nesse projeto os componentes SimpleORM e o Router4D. Mas todas as vezes que adiciono a unit SimpleDAO no meu projeto, a minha classe "_Routers" deixar de registrar as rotas e minhas pages. Com isso aparece o erro "Classe TViewHome not found".
O estranho é que a classe está registrada e o projeto está compilando normalmente, mas quando ele é instanciado e o TRouter4D tenta carregar a "ViewHome", o erro é apresentado. E quando eu removo a unit SimpleDAO, o projeto volta a funcionar normalmente.
Este é o link dos fontes do projeto para que este caso seja analisado pela equipe:
https://drive.google.com/file/d/1myXpPrJQNxhCbsOWS0KgkKkOHVXV47B4/view?usp=sharing
Suporte a Store Procedure
Existe compatibilidade com RestRequest4Delphi?
Como listar o ultimo registro de uma tabela?
Estou fazendo uma venda, na hora de salvar os itens da venda, como saber o código da ultima venda salva. Para inserir aos itens da venda?
As modificações vou enviar por PR
Olá pessoal, baixei o SimpleORM para usar em um pequeno projeto.
Uso Delphi Tokyo 10.2, e está acusando erro na linha 238 do arquivo SimpleRTTI.pas ao tentar compilar.
Erro:
[dcc32 Error] SimpleRTTI.pas(233): E2003 Undeclared identifier: 'tkMRecord'
Aparentemente, na versão Tokyo 10.2, esse TypeKind ainda não foi implementado.
No arquivo System.pas ele existe, mas está comentado.
Linha 1418 do System.pas:
// Sync with compiler internals
TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat,
tkString, tkSet, tkClass, tkMethod, tkWChar, tkLString, tkWString,
tkVariant, tkArray, tkRecord, tkInterface, tkInt64, tkDynArray, tkUString,
tkClassRef, tkPointer, tkProcedure {, tkMRecord});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.